Repository navigation
Conversation
TinyHumansModel::new_with_credential takes a resolver that says whether each bearer is the session token or an API key, and TinyHumansAuthFailure::credential() returns the kind the failing request itself carried (captured per dispatch through a task-local the bearer source writes). A host can then tell a rejected API key from an expired session even when the credential changes with requests in flight, instead of reading its own 'last resolved' state. new() is unchanged and reports None.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
Tiny Sweeper reviewReviewed head: FindingsNo active actionable findings. Advisory notes
Resolved this pass
Verdict: Ready for maintainer review · Priority: medium Diagnostics and supporting detailsFull summaryPull request purpose (title): feat(tinyhumans): report the credential kind with each auth failure. Purpose (from the title and description): `feat(tinyhumans): report the credential kind with each auth failure`. The pull request lets `TinyHumansModel` report which credential kind — `Session` or `ApiKey` — a failed managed request was actually sent with, so a host can sign the user out only on a session 401 and treat an API-key 401 as a rejected key, rather than misattributing a late 401 to whatever credential was resolved last. The two findings from the prior cycle (reading the stream-open credential outside the scope, and capturing the kind outside the scope closure) are reported as fixed by the description and tests lanes. One gap remains: in-band stream-item failures still report the credential resolved at stream open rather than the credential the failing in-band request carried, which the tests lane says should be fixed before merge. Review snapshot
Completeness: Complete Features
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. Before mergeNone. Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
…h-failure-credential-kind # Conflicts: # CHANGELOG.md
Summary
TinyHumansModelcan now report which credential each failed request was sent with.TinyHumansModel::new_with_credential(base_url, model, default_model, resolver): the resolver returns aTinyHumansCredential { bearer, kind }, wherekindisTinyHumansCredentialKind::SessionorApiKey.TinyHumansAuthFailure::credential() -> Option<TinyHumansCredentialKind>: the kind the failing request itself carried. It isNonefor a model built with plainnew, which is otherwise unchanged.How it works: the bearer is resolved inside the generic
OpenAiModel, so aProviderErrorcan't name the credential behind it.invokeand stream-open now run inside atokio::task_local!scope.ResolvedBearer::current()records the kind it handed out into that scope, and the failure handler reads it back. Stream items reuse the kind captured when the stream opened. Outside a dispatch scope (the readiness probe), nothing is recorded andcredential()isNone.Why
The host (openhuman) must sign the user out only on a 401 for the session credential; an API-key 401 is a rejected key. The host used to record "the credential last resolved" in shared state, which a request in flight across a credential switch can misattribute: a late API-key 401 then looks like a session 401. Context: tinyhumansai/openhuman#8240 (review thread on credential provenance). The host will move to
new_with_credentialonce this lands.Where the task-local is read
The kind is read inside the task-local scope on both paths.
SENT_CREDENTIAL.with(Cell::get)runs inside theasyncblock passed toSENT_CREDENTIAL.scope(...), and the block returns(result, credential)from within the scope:invoke_operation:mod.rs:387-391.stream(): stream-open,mod.rs:480-484. In-band stream items reuse thecredentialcaptured there.ResolvedBearer::current()writes it withSENT_CREDENTIAL.try_with(...)(mod.rs:585). Outside a dispatch scope that's a no-op, so the readiness probe reportsNone.The stream-open path is covered by
managed_auth_failure_reports_the_credential_its_request_carried. Its third request ismodel.stream(...), and the test asserts(TinyHumansOperation::Stream, Some(TinyHumansCredentialKind::Session)).Tests
managed_auth_failure_reports_the_credential_its_request_carried: the resolver switches from API key to session between requests. The failures reportApiKey(invoke), thenSession(invoke and stream-open).a_plain_bearer_resolver_reports_no_credential_kind:newreportsNone.managed_auth_callback_reports_typed_provenance_for_each_operationstill passes.cargo test -p tinyinference-llm --lib -- providers::tinyhumans::tests::managed_auth providers::tinyhumans::tests::a_plain_bearergave 3 passed.CHANGELOG.mdhas an Unreleased entry. The change is additive: no existing signature changes, and the new field is private.