From 4f672f6035e1d76890f6e70740788c8cd2953689 Mon Sep 17 00:00:00 2001 From: Christie Williams Date: Mon, 5 Oct 2026 14:54:17 -0400 Subject: [PATCH] test(client): assert a declined foreign payload is not a commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TESTING.md §3.25 asks for all four shapes that reach payload-transferred with nothing to apply. The test covered three; the declined foreign payload was missing, so dropping `not foreign` from `applied` still passed the suite, because the foreign tests assert only the basis. Add it, priming the reader with a skill commit so the payload is recognisably foreign, and assert the committed set is unchanged rather than empty. Co-Authored-By: Claude Opus 5.5 --- packages/client/tests/test_skills_fdv2.py | 56 +++++++++++++++-------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/packages/client/tests/test_skills_fdv2.py b/packages/client/tests/test_skills_fdv2.py index cfbde0c1..1864229b 100644 --- a/packages/client/tests/test_skills_fdv2.py +++ b/packages/client/tests/test_skills_fdv2.py @@ -956,36 +956,56 @@ def test_transfer_none_holds_everything_and_commits_nothing(self) -> None: def test_a_transfer_that_applied_nothing_is_not_a_commit(self) -> None: """ - Three shapes reach ``payload-transferred`` with no pending set to apply: - an intent code this SDK does not recognise, a ``none`` intent, and a - lone transfer under no intent at all. None of them applied anything, so - none of them claims anything — neither a commit, which is what publishes - the first payload ``write_skills("*")`` prunes on, nor an up-to-date - answer, which only the server can give and only the ``none`` intent - does, on its own event. + Four shapes reach ``payload-transferred`` with nothing to apply: an + intent code this SDK does not recognise, a ``none`` intent, a lone + transfer under no intent at all, and a foreign payload, which built a + pending set and threw it away. None of them applied anything, so none + of them claims anything — neither a commit, which is what publishes the + first payload ``write_skills("*")`` prunes on, nor an up-to-date answer, + which only the server can give and only the ``none`` intent does, on + its own event. The transfer is still a wire fact, counted either way. """ - for payload_events in ( - events( - ("server-intent", server_intent("xfer-future")), - ("put-object", put_skill()), - ("payload-transferred", transferred("basis-1")), + for prior, payload_events in ( + ( + [], + events( + ("server-intent", server_intent("xfer-future")), + ("put-object", put_skill()), + ("payload-transferred", transferred("basis-1")), + ), ), - events( - ("server-intent", server_intent("none")), - ("payload-transferred", transferred("basis-1")), + ( + [], + events( + ("server-intent", server_intent("none")), + ("payload-transferred", transferred("basis-1")), + ), + ), + ([], events(("payload-transferred", transferred("basis-1")))), + ( + # A payload is foreign only once the skill payload is known, + # which takes a commit first. + full_payload(("put-object", put_skill()), state="basis-skills"), + events( + ("server-intent", server_intent("xfer-full", "env-flags")), + ("put-object", put_skill("other")), + ("payload-transferred", transferred("basis-flags")), + ), ), - events(("payload-transferred", transferred("basis-1"))), ): held = _SkillObjectSet() reader = _ProtocolReader(held) + drive(reader, prior) + before = held.all_raw() + transfers = reader.diagnostics.payloads_transferred outcome = drive(reader, payload_events)[-1] assert outcome.committed is False assert outcome.up_to_date is False assert outcome.basis is None - assert len(held) == 0 - assert reader.diagnostics.payloads_transferred == 1 + assert held.all_raw() == before + assert reader.diagnostics.payloads_transferred == transfers + 1 def test_a_put_after_a_none_intent_is_applied(self) -> None: """``none`` means current, not finished: later edits follow it on the