WRK-2948: managed Habitat delegated identity and Ticino OBO lifecycle - #16
Open
nicky-isaacs-awoo wants to merge 36 commits into
Open
nicky-isaacs-awoo wants to merge 36 commits into
nicky-isaacs-awoo wants to merge 36 commits into
Conversation
Closed
13 tasks
nicky-isaacs-awoo
force-pushed
the
datadog/patch/WRK-2948-managed-sandbox-context
branch
from
September 18, 2026 02:19
b7c4915 to
33c4c0e
Compare
nicky-isaacs-awoo
force-pushed
the
datadog/patch/WRK-2948-managed-sandbox-context
branch
from
September 18, 2026 13:13
4a3a4ee to
2754d1e
Compare
nicky-isaacs-awoo
marked this pull request as ready for review
September 18, 2026 14:13
carterbs
approved these changes
Sep 18, 2026
Co-authored-by: Nick Isaacs <nick.isaacs@datadoghq.com>
Introduce omnigent/onboarding/sandboxes/context.py as the portable, framework-neutral boundary for carrying the signed-in user's identity context (session, user, renewable token provider) across the managed sandbox provisioning path via ContextVar semantics. Co-authored-by: Nick Isaacs <nick.isaacs@datadoghq.com>
AuthProvider gains an optional get_identity_token_provider method. OIDC mode resolves the request's sess_ handle through the same validated credential path as get_user_id and returns a provider bound to that credential session and its verified owner; every call re-validates and returns or refreshes the current ID token via the token manager. Header and accounts modes default to None, and mismatched, missing, or revoked sessions fail closed. Co-authored-by: Nick Isaacs <nick.isaacs@datadoghq.com>
The session-create route resolves the owner's identity-token provider and binds a ManagedSandboxContext around only the asyncio.create_task call that schedules the background launch. The copied context reaches launcher construction and provision through asyncio.to_thread without any launcher signature or factory change; the request task keeps no scope after scheduling. Co-authored-by: Nick Isaacs <nick.isaacs@datadoghq.com>
Cross-boundary integration test composing the full chain end to end: an authenticated OIDC request scopes the managed-sandbox context around the background launch, the real ProductionHabSandboxLauncher reads the delegated Ticino ID token through the real OIDC token manager, and a fake exchange client trades it (workload bearer supplied separately, audience hab) for the OBO bearer that CreateHab carries to a fake Habitat gRPC service. Skips unless OMNIGENT_HAB_LAUNCHER_PATH points at the hab_launcher package. Co-authored-by: Nick Isaacs <nick.isaacs@datadoghq.com>
Records the pre-deployment red-state expectations and the acceptance sequence for delegated Habitat provisioning, with the prerequisite pairing gates. Co-authored-by: Nick Isaacs <nick.isaacs@datadoghq.com>
nicky-isaacs-awoo
force-pushed
the
datadog/patch/WRK-2948-managed-sandbox-context
branch
from
September 20, 2026 13:40
227a85f to
beb7009
Compare
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.
Related issue
Part of epic WRK-2948 (Omnigent trial). Supersedes #14, which targeted
main; this PR targetsdatadog/mainper the Omnigent Developer Guide branch model.Summary
Motivation
Omnigent currently turns an OIDC login into its own self-contained session JWT. That is enough to authenticate later HTTP requests, but it discards the upstream Ticino credential needed to perform an on-behalf-of exchange when a managed Habitat sandbox is created, woken, relaunched, or deleted. Those lifecycle operations can also happen after the original request, so they must recover the exact owner's identity without falling back to another user or to a shared service credential.
What changed
oidc_sessionsrow and give the browser/CLI an opaquesess_...handle. Request authentication resolves that handle off the event loop; logout revokes it and erases its encrypted credentials.ELI5: Omnigent keeps the signed-in user's Ticino credentials encrypted on the server and remembers which credential owns each managed Habitat. Whenever that Habitat needs lifecycle work, Omnigent acts as the same user; it never silently substitutes a different identity.
HTTP and database impact
/auth/callbackresponses issue an opaque session handle when the OIDC store is configured, and/auth/logoutnow revokes that stored provider session before clearing the cookie.cleanup_pendingso callers can distinguish confirmed provider deletion from deferred cleanup.oidc_sessionstable, refresh-coordination columns, and non-secret managed-lifecycle columns onhosts(sandbox_session_id,sandbox_credential_session_id,sandbox_lifecycle_state, andsandbox_cleanup_attempts). OIDC lookups includeworkspace_id, matching the composite indexes and preventing cross-workspace resolution.OMNIGENT_OIDC_CREDENTIAL_KEY, separate from the cookie-signing secret.Test Plan
uv run --extra dev pre-commit run --all-filespassed, including Ruff and Pyrefly.Demo
This is a server-side authentication and managed-lifecycle change; the reproducible local harness and manual real-Habitat flow are described in the Test Plan.
Type of change
Test coverage
Coverage notes
The automated suite covers workspace isolation, opaque-session authentication and revocation, refresh coordination, identity binding, lifecycle recovery, cleanup tombstones, and fake-service OBO behavior. The real cross-repository Habitat check remains opt-in because it requires an internal
hab-launchercheckout and live credentials; that path was also verified manually against the real Habitat environment.Changelog
Managed Habitat sandboxes now use the signed-in user's renewable Ticino identity throughout provisioning and lifecycle operations.