Skip to content

Record the answering endpoint in target responses - #119

Closed
avalyset wants to merge 2 commits into
SimulaMet:mainfrom
avalyset:feat/endpoint-provenance
Closed

avalyset wants to merge 2 commits into
SimulaMet:mainfrom
avalyset:feat/endpoint-provenance

Conversation

@avalyset

Copy link
Copy Markdown
Contributor

For an audit to be reproducible, its record should say which endpoint answered: ASRTarget, DecisionTarget and HTTPAppTarget now add an endpoint block to TargetResponse.raw with the scheme, host, port and via_proxy (whether urllib.request.getproxies()/proxy_bypass() route the request through a proxy), merged into the provider's response without overwriting its fields; a response that is not a dict, or already has an endpoint key, is wrapped as {"response": ..., "endpoint": ...}.
The block never contains the path, query, userinfo, headers or API keys; raw is not written to saved results today, so the block is available to callers of send() only.
Each of the three targets warns once at construction when its URL is plain http:// to a host other than loopback (localhost, 127.0.0.0/8, ::1).
ASRTarget now uploads the audio as audio plus the lowercased extension, so the local filename is not sent with the upload; the MIME type is still guessed from the original filename exactly as before.
pytest -p no:randomly gave 1611 passed, 2 skipped on main at 6636ae8 before the change and 1623 passed, 2 skipped, 0 failed after it (12 new tests in tests/test_endpoint_provenance.py), and ruff check --select E9,F821 . passes.

AI disclosure: implemented with Claude Code.

ASRTarget, DecisionTarget and HTTPAppTarget add an endpoint block (scheme,
host, port, via_proxy) to TargetResponse.raw, warn once at construction on
plain http to a non-loopback host, and create their client through one
helper. ASRTarget uploads the file as audio<suffix>.
@SushantGautam

Copy link
Copy Markdown
Collaborator

Superseded by #131, which carried these same two commits (endpoint provenance + cleartext warning fix) and added DecisionTarget client reuse/retries. Merged into dev via #131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants