fix(FunctionResult): tap direction is speak/listen/both, and always emitted - #86
Closed
grandcamel wants to merge 1 commit into
Closed
fix(FunctionResult): tap direction is speak/listen/both, and always emitted#86grandcamel wants to merge 1 commit into
grandcamel wants to merge 1 commit into
Conversation
…mitted The tap() helper disagreed with the SWML schema (and the platform docs) twice over. It accepted and emitted "hear", which is not a tap direction — the verb's enum is speak/listen/both, exactly the set record_call() already uses — so direction="hear" produced SWML the platform rejects; it now raises the existing ValueError instead of silently emitting a dead tap. And its omit-if-default logic assumed the verb's default matches the helper's "both" when the verb actually defaults to "speak", so tap(uri) — documented as tapping both directions — produced a speak-only tap. direction is now always emitted; codec/rtp_ptime omissions stay (their helper defaults match the verb defaults). Note for the port audit: tap.direction's Literal feeds python_signatures.json in porting-sdk as enum<...>, so the oracle needs a regen alongside this change. docs/swaig_reference.md and docs/api_reference.md updated to the real enum (api_reference had a third variant — inbound/outbound plus a G722 codec and sip: URIs that the helper never accepted). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MgA3KeCEPMKMJVvroZY1wV
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.
Summary
FunctionResult.tap()disagreed with the SWML schema (and the live platform docs, https://signalwire.com/docs/swml/reference/tap) in two ways, both of which made it emit taps that don't do what the caller asked:"hear"is not a SWML direction. The verb's enum isspeak | listen | both; the helper accepted and emitted"hear". Atap(uri, direction="hear")produced SWML the platform rejects.record_call()in the same class already uses the correct("speak", "listen", "both")set — tap was the outlier.The omit-if-default logic assumed the platform default is
"both"; it's"speak". The helper only emitteddirectionwhen it differed from its own"both"default, sotap(uri)— documented as tapping both directions — actually produced a speak-only tap. Thecodec/rtp_ptimeomissions are unaffected (their helper defaults match the schema defaults).Fix
directionis nowLiteral["speak", "listen", "both"], matchingrecord_calland the schema."hear"now raises the existingValueError— it could never produce a working tap, so no working caller regresses; a broken silent tap becomes a loud error.directionis always emitted, so the helper's documented"both"default is what the platform actually executes.docs/swaig_reference.mdanddocs/api_reference.mdupdated to match (api_referencehad a third wrong enum — "inbound"/"outbound" — plus aG722codec andsip:URIs the helper never accepted).Behavior note (please review)
For existing callers of
tap(uri)with no explicit direction, emitted SWML changes from (no direction ⇒ platform speak-only) to an explicit"direction": "both"— i.e. behavior now matches what the helper has always documented. If anyone has been relying on the accidental speak-only behavior, this PR changes what their tap captures. The alternative (documenting"speak"as the default instead) preserves accidental behavior but breaks the documented contract; happy to switch if that's preferred.Cross-repo note
tap.direction'sLiteralfeeds the port-audit oracle (python_signatures.jsonin porting-sdk) as anenum<...>; the oracle needs a regen alongside this change (test_validated_closed_sets_declared_as_literalpins the tuple in-repo and is updated here).🤖 Generated with Claude Code
https://claude.ai/code/session_01MgA3KeCEPMKMJVvroZY1wV