Skip to content

scalar_http client: cookie-session only, not Bearer (i3 auth fidelity) - #33

Merged
github-actions[bot] merged 2 commits into
masterfrom
feat/elements-full-coordinate
Jul 20, 2026
Merged

github-actions[bot] merged 2 commits into
masterfrom
feat/elements-full-coordinate

Conversation

@Amantux

@Amantux Amantux commented Jul 20, 2026

Copy link
Copy Markdown
Owner

External review #2 (client auth fidelity). The real i3 authenticates via the sessionID session cookie; the scalar_http client was hybrid — it relied on the cookie jar AND also sent Authorization: Bearer using the token the emulator happens to return in the login body. A real appliance doesn't accept that header, so the Bearer path let the client 'work' against the emulator while diverging from the real contract.

  • _headers() no longer adds Authorization; auth rides purely on the cookie jar (login sets sessionID, httpx persists it, 401 still triggers a transparent re-login). The body token is retained for diagnostics only.
  • New contract test asserts no Authorization header is sent, the sessionID cookie is present, and a cookie-authenticated read still works — guarding against regressing to the Bearer artifact.
  • 18 scalar_http contract tests green against the in-process emulator.

Note: I investigated the elements-coordinate wire change (the other i3-fidelity item) and deliberately did NOT do it — test_aml_diagnostics.py asserts the current "1,bay,slot" string, and the real 5-field format can't be certified without an appliance capture. Guessing a parity wire contract would be wrong; the corpus already flags that gap for certification.

https://claude.ai/code/session_012K5Zjc2bggcyJtFbz2D4Pw

…lity)

The real i3 authenticates via the sessionID session cookie; the client was
hybrid — it relied on the cookie jar AND also sent Authorization: Bearer using
the token the EMULATOR happens to return in the login body. A real appliance does
not accept that header, so the Bearer path let the client "work" against the
emulator while diverging from the real contract (external review #2).

- _headers() no longer adds Authorization; auth rides purely on the cookie jar
  (login sets sessionID; httpx persists it; 401 still triggers a transparent
  re-login). The body token is retained for diagnostics only.
- New contract test asserts the client sends no Authorization header, the
  sessionID cookie is present, and a cookie-authenticated read still works —
  guarding against regressing to the Bearer artifact.

18 scalar_http contract tests green against the in-process emulator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012K5Zjc2bggcyJtFbz2D4Pw
Copilot AI review requested due to automatic review settings July 20, 2026 16:11
These in-process (TestClient) real-i3 client tests were not run by any PR CI job
— the selective-coverage gap again. Wire them into backend-tests so the client
contract (incl. cookie-session auth) is verified at PR time, not only post-merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012K5Zjc2bggcyJtFbz2D4Pw

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Quantum Scalar i3 authentication fidelity in the scalar_http client by ensuring authentication is performed exclusively via the sessionID session cookie (as on real appliances), rather than also sending an emulator-only Authorization: Bearer header.

Changes:

  • Remove Authorization: Bearer injection from ScalarHttpSession._headers() so requests rely solely on the cookie jar.
  • Update ScalarHttpSession.login() documentation to clarify the response-body token is diagnostic-only.
  • Add a contract test to guard against reintroducing Bearer-based authentication.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
openblade/hardware/scalar_http/session.py Stops adding Authorization: Bearer and documents cookie-session as the sole auth mechanism.
tests/i3/test_scalar_http_session.py Adds a contract test to ensure cookie-based auth is used and Bearer auth is not relied upon.

Comment on lines +68 to +78
def test_scalar_http_session_authenticates_via_cookie_not_bearer(
emulator_client: TestClient,
) -> None:
# Real i3 fidelity: auth rides on the sessionID cookie, never an Authorization
# header. Guards against regressing to the emulator-only Bearer artifact.
session = _session(emulator_client)
session.login()

assert "Authorization" not in session._headers()
assert "sessionID" in emulator_client.cookies # cookie jar carries the session
assert session.get_json("/aml/system/status") # cookie-authenticated read works
@github-actions
github-actions Bot merged commit 042ee74 into master Jul 20, 2026
9 of 16 checks passed
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