Repository navigation
test(skill-reco): pin the suggest_skill wire contract, and make its field name compiler-checked - #808
Merged
Merged
Conversation
…ield name compiler-checked
The recommendation had no test anywhere along its wire path, so the only way a
regression could surface was as "the card never appears". Three additions, plus
the fix that removes the failure mode the tests were written to catch.
The handler wrote its payload as hand-written JSON:
serde_json::json!({"skill": ...})
and `future_rpc::encode` reads that JSON back into `SuggestSkillPayload` with
`serde_json::from_value(..).ok()?`. A renamed key therefore does not fail
anything: the encoder returns `None`, the response carries no typed payload, and
the desktop's `.catch(() => null)` turns that into "no recommendation". The agent
still logs a successful recommendation, so the feature would quietly stop working
with healthy-looking logs. The handler now serializes the shared payload type, so
a rename breaks the build in all three places instead (verified by renaming the
field: the encoder, the decoder and the handler all stop compiling).
Tests, each verified to fail on the drift it covers:
* `suggest_skill_response_encodes_into_the_typed_payload` (agent) — runs the
handler and feeds its `data` object to the encoder, asserting a typed payload
comes back. Spelled with the wrong key, it fails with
`skill key must be present: {"suggestion":null}`.
* `suggest_skill_round_trips_between_typed_payload_and_json` and its empty-answer
sibling (rpc) — the JSON → proto → JSON path the desktop and the mobile relay
both parse. The empty case asserts `skill` decodes as `null` rather than going
missing, which is what the client's `Option<SkillCandidate>` is written against.
No wire change: `{"skill": null}` and `{"skill": {...}}` serialize exactly as
before, which the empty-answer test pins.
The suite this came out of (scripts/skill_reco/suggest-skill-tests.py, run
against an isolated agent home) exercised 43 checks over the RPC: the typed-payload
shape, every failure collapsing to "no recommendation", input that must never
reach the network (blank query or no candidates, with a credential present so the
input check is what stops it), the refusal gate, order independence, the 254
candidate cap against the gateway's 255-option limit, CJK text, and concurrency.
huichen
enabled auto-merge (squash)
September 24, 2026 00:54
The suite that found the payload-drift risk (43 checks, five suites) lived in /tmp and would have been lost. It is committed now, documented in the harness doc, and deliberately kept out of CI: it needs grpcurl, a real credential and a live gateway, so it costs money and depends on the network. future agent --home /tmp/reco-test --verbose --log-file python3 scripts/skill_reco/suggest-skill-tests.py # ~33 calls, ≈¥0.04 python3 scripts/skill_reco/suggest-skill-tests.py --only A,B,D # the free suites python3 scripts/skill_reco/order-sensitivity.py --runs 8 Suites: A credential/availability, B input validation (no network), C real gateway, D protocol shape and concurrency, E boundaries. `--only A,B,D` spends nothing. order-sensitivity.py is separate because its question needs a distribution, not an answer: one pair of calls looked order-sensitive during the pass, and repeating each order showed both produced the same set of answers — run-to-run noise, not ordering. That run also produced the more useful finding that the option text decides near-miss races (one extra clause took an ambiguous prompt from 0/16 to 12/12). Both scripts take FUTURE_REPO and RECO_TEST_HOME from the environment instead of hard-coding this checkout.
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.
The problem
The recommendation had no test anywhere along its wire path, so a regression could
only surface as "the card never appears". Worse, one class of regression could not
surface at all.
The handler wrote its payload as hand-written JSON:
and
future_rpc::encodereads that JSON back intoSuggestSkillPayloadwithserde_json::from_value(..).ok()?. A renamed key therefore fails nothing: theencoder returns
None, the response carries no typed payload, and the desktop's.catch(() => null)turns that into "no recommendation" — while the agent stilllogs a successful recommendation. The feature would quietly stop working with
healthy-looking logs.
The fix
The handler serializes the shared payload type, so the field name is the
compiler's business on both sides instead of a string that only matches by
convention. Verified by renaming the field: the encoder, the decoder and the
handler now all fail to compile (before: silent, green, broken).
No wire change —
{"skill": null}and{"skill": {...}}serialize exactly asbefore, which the empty-answer test pins.
The tests
Each was verified to fail on the drift it covers:
suggest_skill_response_encodes_into_the_typed_payload(agent)skill key must be present: {"suggestion":null}suggest_skill_round_trips_between_typed_payload_and_json(rpc)suggest_skill_round_trips_an_empty_answer_as_a_null_skill(rpc)skilldecodes asnullrather than going missing — what the client'sOption<SkillCandidate>is written againstWhat it came out of
An end-to-end pass over the RPC against an isolated agent home (own socket,
database and lock), 43 checks in five suites, all passing. Two findings beyond
the tests above:
client's deadline was 1500 ms — paid-for answers nobody saw. feat(skill-reco): lock the composer for the wait, and give it 3 s #807 has since
raised it to 3000 ms; this data independently supports that choice. The large
option tables (≈141 candidates, ≥2k tokens) never exceeded 1500 ms, so the tail
comes from round-trip jitter rather than payload size.
this photo, then make a PDF slide deck") picked the image skill 12/12 with one
extra clause in its description, and 0/16 without it — the candidate text, not
the request, decides those.
The suite itself (a plain-python grpcurl driver) stays out of the repo: it needs a
real credential and a live gateway, so it cannot run in CI.
Verified:
future-rpc123 (was 121),future-agent1869 (was 1868), fmt andclippy clean.