Repository navigation
test(backend): pin both seat-field filters on the machine heartbeat (TASK-067) - #1763
Merged
Merged
Conversation
samxu01
force-pushed
the
kai/machine-seat-field-whitelist
branch
from
September 18, 2026 20:23
ab9b989 to
75af59d
Compare
lilyshen0722
force-pushed
the
kai/machine-seat-field-whitelist
branch
from
September 19, 2026 16:22
75af59d to
8e105a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two tests pinning the two independent filters that keep
machine.agentStatesat four fields. A daemon reports ten seat fields
(
cli/src/lib/daemon-supervisor.js:73-85agentStates()); the server stores four.normalizeAgentStates,machineService.ts:28-47keeps only the four stored seat fields …strict, against the declared subdocMachine.ts:41-50(four paths, nostrictoption)drops undeclared seat paths at the schema too …Each filter alone holds the stored shape at four fields, so either one can be
weakened without the suite noticing — that is the gap, and it is why there are
two tests rather than one.
normalizeAgentStatesentirely, then reads the raw collection(
mongoose.connection.collection('machines')) and asserts four keys.Honest limit
Asserting filter 1 higher up does not work: with the schema in place, a spread in
normalizeAgentStatesis invisible atrecordMachineHeartbeatand atserializeMachine(the view is rebuilt field by field), so a throwaway test atthose surfaces passed under the mutation. The pure function is the only place
filter 1 can be checked — and the corollary is that neither test protects against
a live leak today; they are tripwires for the plausible sequence (spread here,
then widen the schema).
Verification
cd backend && npx jest __tests__/unit/services/machineService→ 7 passed...eadded to the objectnormalizeAgentStatesreturns → only filter 1fails, filter 2 and the other five stay green.
strict: falseadded toMachine.ts's schema options → only filter 2fails, filter 1 and the other five stay green.
Both reverted.
.jscorpus(the burn-down in
CLAUDE.md); the added lines introduce none.Scope
backend/__tests__/only — tests-only, and the version guard watches$pkg/srcfor
cliandcommonly-mcp, so no version bump.