From 72ded17946923b3195e6874ad4bf5abb72c36391 Mon Sep 17 00:00:00 2001 From: Dotta Date: Tue, 29 Sep 2026 12:05:52 -0500 Subject: [PATCH] test(runner): distinguish Pi blank transport from form support Co-Authored-By: Paperclip --- doc/architecture/runner-pi-capabilities.md | 9 ++++++++- .../src/drivers/acpx/pi-acp-runtime.test.ts | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/architecture/runner-pi-capabilities.md b/doc/architecture/runner-pi-capabilities.md index 4d28ab150d6..0749b449f3c 100644 --- a/doc/architecture/runner-pi-capabilities.md +++ b/doc/architecture/runner-pi-capabilities.md @@ -8,7 +8,14 @@ name. Titles and select labels admit at most 1,000 UTF-16 code units, matching the canonical question contract. Invalid owned arguments fail before a UI promise; unsupported external UI requests emit an explicit error notice and stop the session. The editor draft requires the shared `initialText` normalization and editable UI -roundtrip. These repairs change the native closure and require fresh qualification; +roundtrip. Blank initial drafts are valid, but accepted empty or whitespace-only +input/editor answers are not currently representable: the canonical required-text +form prevents submission with a required-answer message, and its response +validator rejects blank text. Making +Pi fields optional alone would still drop those answers; no adapter fallback +invents an empty response. The transport distinguishes empty accept from cancel, +but that direct bridge property is not full Product support. A future explicit +canonical empty-text opt-in would need matching persisted-response and UI checks. These repairs change the native closure and require fresh qualification; no v7 paid Product or Runner proof exists yet. The canonical [v7 declaration](../../packages/paperclip-runner/test-fixtures/pi-acp/profile-v7-identity.json) binds the exact wrapper, helper, extension and three target closures. diff --git a/packages/paperclip-runner/src/drivers/acpx/pi-acp-runtime.test.ts b/packages/paperclip-runner/src/drivers/acpx/pi-acp-runtime.test.ts index e4999afa43d..41ad10a0885 100644 --- a/packages/paperclip-runner/src/drivers/acpx/pi-acp-runtime.test.ts +++ b/packages/paperclip-runner/src/drivers/acpx/pi-acp-runtime.test.ts @@ -69,7 +69,7 @@ describe("Pi ACP bridge", () => { expect(f.process.sendExtensionUiResponse).toHaveBeenCalledExactlyOnceWith({ id: "q1", ...expected }); }); - it("retains blank editor prefill and distinguishes an accepted empty string from cancellation", async () => { + it("transport preserves blank editor prefill and empty accept independently of canonical required validation", async () => { const f = fixture(); f.connection.unstable_createElicitation.mockResolvedValue({ action: "accept", content: { answer: "" } }); await f.bridge.handle({ id: "blank", method: "editor", title: "Draft", prefill: "" }); expect(f.connection.unstable_createElicitation.mock.calls[0]![0]).toMatchObject({ requestedSchema: { properties: { answer: { default: "" } } } }); @@ -79,6 +79,21 @@ describe("Pi ACP bridge", () => { expect(f.process.sendExtensionUiResponse).toHaveBeenLastCalledWith({ id: "dismissed", cancelled: true }); }); + it.each(["input", "editor"])("documents canonical %s blank-answer rejection without inventing an empty accept", async method => { + const f = fixture(); + f.connection.unstable_createElicitation.mockImplementation(async request => { + const normalized = normalizeAcpFormElicitation(request)!; + const question = normalized.questionSet.questions[0]!; + expect(question.required).toBe(true); + for (const text of ["", " \n\t"]) { + expect(() => normalized.accept({ schema: "paperclip.question_response.v1", answers: { [question.id]: { text } } })).toThrow("is required"); + } + return normalized.accept({ schema: "paperclip.question_response.v1", answers: { [question.id]: { text: "\nAccepted text\n" } } }); + }); + await f.bridge.handle({ id: "canonical", method, title: "Draft", prefill: "" }); + expect(f.process.sendExtensionUiResponse).toHaveBeenCalledExactlyOnceWith({ id: "canonical", value: "\nAccepted text\n" }); + }); + it.each(["a".repeat(1000), "界".repeat(1000), "🌒".repeat(500)])("passes the canonical character limit through the real form normalizer", async (label) => { const f = fixture(); f.connection.unstable_createElicitation.mockImplementation(async request => {