Skip to content

feat: add the authenticated runtime seam - #179

Merged
altaywtf merged 5 commits into
next-rollout/stack-cifrom
next-rollout/runtime-seam
Aug 30, 2026
Merged

feat: add the authenticated runtime seam#179
altaywtf merged 5 commits into
next-rollout/stack-cifrom
next-rollout/runtime-seam

Conversation

@altaywtf

@altaywtf altaywtf commented Aug 29, 2026

Copy link
Copy Markdown
Member

Part of #123
Refs #130
Preserves #129

Summary

  • Add one PutioRuntime that privately owns the shared authenticated PutioSDK used by session and file operations.
  • Convert mutable SDK responses into immutable, Sendable account and file snapshots; expose root and nested first-page listing without credentials, cursors, or token-bearing URLs.
  • Preserve cancellation, classify runtime failures, expire the whole session on 401/403, and reject responses from superseded authentication generations.
  • Compose the iOS shell around the runtime so the browser layer can consume the seam next.

This gives the rollout one safe authenticated boundary before file-browser UI and playback land.

Reviewer Guide

  • Highest-risk area: authentication-generation checks across restore, sign-out, a fresh sign-in, duplicate sign-in attempts, and in-flight file requests.
  • Start with PutioRuntime.swift, then PutioSessionStore.swift and the gated race tests in PutioRuntimeTests.swift.

Visual Aids

Validation

  • mise run verify
  • Affected iOS shell exercised with the deterministic signed-in recording scenario
  • Proof captured with mise run harness -- record --platform ios --scenario signed-in --record-seconds 7
  • Proof published separately with the repository harness
  • Additional targeted checks:
    • 23 focused runtime/session tests pass.
    • The recording manifest pins ffb51a7650ec7071e1c3d3a6bd7ff3e1fa5800c5; app stdout/stderr are empty.
    • Codex-high Slopguard reviewed the complete 90959c0...ffb51a7 branch diff and returned clean with 0 findings.

Sanity Checks

  • Signed-out listing issues no HTTP request.
  • Cancellation retains the signed-in session and persisted token.
  • 401/403 clear credentials and expire the shared session.
  • Old-session success and auth-failure responses cannot affect a fresh session.
  • Sign-in is blocked while remote logout is pending; a late restore cannot erase an in-flight sign-in.
  • A duplicate sign-in attempt cannot clear the first OAuth transaction or reject its valid callback.

Benchmarks

N/A — this layer adds runtime contracts, not a performance-sensitive UI path.

Notes

Copilot AI lite review requested due to automatic review settings August 29, 2026 13:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T08:25:25.422260Z c5b7f4e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

🟢 Approval recommended

The session-generation gating, session-expiry behavior, and runtime snapshot/redaction goals are covered by focused tests and the integration updates are consistent with the new runtime seam.

Pull request overview

This PR introduces an authenticated runtime seam (PutioRuntime) that owns the shared authenticated PutioSDK, while converting SDK models into immutable, Sendable snapshots and hardening session correctness via authentication-generation gating and 401/403 session expiry. It composes the iOS shell around the runtime so downstream browser/playback layers can depend on a safe authenticated boundary.

Changes:

  • Added PutioRuntime + runtime snapshot models (PutioAccountSnapshot, PutioFileItem, etc.) and mapped first-page root/nested listings without exposing token-bearing URLs.
  • Updated PutioSessionStore to gate restore/sign-in/sign-out via an authenticationGeneration, add .signingOut, and expire the session on auth rejection.
  • Added targeted runtime/session race tests (including gated URLProtocol fixtures) and wired the iOS shell + harness factory to construct and use PutioRuntime.
File summaries
File Description
Packages/PutioCore/Tests/PutioCoreTests/PutioSessionStoreTests.swift Updates assertions for the new account snapshot and adds coverage for restore vs. in-flight sign-in ordering.
Packages/PutioCore/Tests/PutioCoreTests/PutioRuntimeTests.swift Adds comprehensive tests for request sharing, snapshot redaction, error classification, cancellation, and auth-generation races.
Packages/PutioCore/Sources/PutioCore/Session/PutioSessionStore.swift Introduces authentication-generation gating, .signingOut, session expiry behavior, and snapshotting of account info.
Packages/PutioCore/Sources/PutioCore/Runtime/PutioRuntimeModels.swift Adds immutable Sendable runtime-facing models for accounts, files, folder contents, and runtime errors.
Packages/PutioCore/Sources/PutioCore/Runtime/PutioRuntime.swift Implements the authenticated runtime boundary, list operation, cancellation behavior, and SDK error classification + session expiry.
Apps/Shared/Sources/PutioRuntimeFactory.swift Switches harness/runtime construction from a raw session store to the new PutioRuntime.
Apps/iOS/Sources/PutioApp.swift Composes the iOS shell around PutioRuntime and updates UI plumbing to use session state + account snapshot.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b7375a528

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Packages/PutioCore/Sources/PutioCore/Runtime/PutioRuntime.swift
altaywtf and others added 2 commits August 29, 2026 17:23
A callback without a live transaction previously advanced the
authentication generation and forced signed-out state from any session
state. While signed in it kicked a valid session to the sign-in screen
with the keychain token left behind, and during sign-out it made the
post-logout guard bail so neither path cleared the SDK token.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@altaywtf

Copy link
Copy Markdown
Member Author

Second-pass review follow-up; fixes pushed to the branch.

Fixed in c5b7f4ecompleteSignIn's guard-fail path advanced the authentication generation and forced .signedOut from any state. A stray callback while .signedIn kicked a valid session to the sign-in screen with the keychain token left behind, so the next restore() silently signed back in; during .signingOut the advanced generation made the post-logout guard bail, so neither path cleared the SDK token. The path now early-returns outside .authenticating. Covered by testStrayCallbackWhileSignedInIsIgnored, testStrayCallbackAfterCancelIsIgnored, and the gated testStrayCallbackDuringSignOutDoesNotBlockCredentialCleanup.

Flagged upstream in putdotio/putio-sdk-swift#52 — the session store mutates PutioSDK.config on the main actor while the SDK's @concurrent request path reads it on the global executor, unchecked under Swift 5 mode. Latent until concurrent data-plane callers exist; the fix belongs in the SDK.

Recorded as intentionalPutioRuntime classifies cancellation before auth failure, so a real 401 racing task cancellation leaves the session .signedIn until the next request's 401. Cancelled work must not mutate state; the miss self-heals.

Verified: 42 PutioCore tests on c5b7f4e; full mise run verify at stack top f82b0e5.

@altaywtf
altaywtf merged commit e6647d6 into next Aug 30, 2026
1 check passed
@altaywtf
altaywtf deleted the next-rollout/runtime-seam branch August 30, 2026 08:42
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