Skip to content

feat(mecatui): add remote OIDC login and credential lifecycle - #847

Merged
jhrozek merged 42 commits into
mainfrom
split/mecatui-remote-login
Aug 31, 2026
Merged

jhrozek merged 42 commits into
mainfrom
split/mecatui-remote-login

Conversation

@jhrozek

@jhrozek jhrozek commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #790.

Remote mecatui can now enroll and use a target-bound OIDC caller identity when connecting to a remote mecated or mecak8s server.

  • adds public-client Authorization Code + PKCE login through the fixed loopback callback, with bounded and state-gated callback handling;
  • persists credentials in a canonical-target, keyring-wrapped encrypted store and validates, refreshes, rotates, and deletes them safely under a per-target cross-process transaction;
  • keeps refresh activity-gated, classifies only structured invalid_grant failures for cleanup, and gives the TUI explicit recovery choices without browser-login loops;
  • adds idempotent local logout plus best-effort RFC 7009 provider revocation, including a 15-second operation-wide budget that accommodates macOS cluster.local DNS fallback and preserves secret-free failure reporting;
  • extracts the scoped private-HTTPS OIDC client and preserves explicit CA roots, HTTPS-only admission, DNS-pinned endpoint checks, hostname validation, and redirect refusal;
  • adds the Kind + Keycloak remote-login qualification fixture, including the non-loopback host alias and optional offline_access support;
  • documents the remote workflow, refresh prerequisites, recovery model, and revised logout budget across the architecture, TUI, deployment, and public user documentation.

Verification

  • task docs
  • task site:build

The branch also adds focused offline coverage for callback validation, credential lifecycle and storage boundaries, refresh behavior, logout/revocation budgeting, and the Kind fixture configuration.

jhrozek and others added 24 commits August 30, 2026 00:10
Accept the registered IPv4 callback URI while retaining bounded, state-gated
validation and safe rejection diagnostics. Remote mecatui login needs a stable
redirect URI, and operators need actionable failures without exposing callback
values or credentials.

Co-Authored-By: mecatl <[email protected]>
Project sanitized provider and callback-validation failures through the MCP
OAuth adapter so callers can distinguish an authorization refusal from a
transport failure without leaking callback values or credentials.

Co-Authored-By: mecatl <[email protected]>
Extract the issuer/JWKS HTTPS restrictions into an endpoint-scoped client so
private OIDC flows can share DNS-pinned dialing, explicit CA roots, and
redirect refusal instead of duplicating an SSRF-sensitive transport.

Co-Authored-By: mecatl <[email protected]>
Add canonical target identity, owner-only public connection metadata, and
encrypted credential records keyed by the complete OIDC client configuration.
This prevents credentials from being reused across incompatible targets while
keeping tokens out of the registry.

Co-Authored-By: mecatl <[email protected]>
Serialize enrollment per target and coordinate credential writes with registry
updates, compensation, and reconciliation. Reauthentication must not strand a
new token or delete a concurrently rotated credential when persistence fails.

Co-Authored-By: mecatl <[email protected]>
Implement Authorization Code with PKCE, access-token validation, CAS-safe
refresh-token rotation, and local-first best-effort revocation. This gives
remote mecatui targets a durable credential lifecycle without trusting stale
or mis-scoped bearer tokens.

Co-Authored-By: mecatl <[email protected]>
Cover enrollment, refresh, logout, and persistence races at their durability
boundaries so changes cannot silently orphan credentials, lose rotation, or
turn local cleanup failures into successful logout.

Co-Authored-By: mecatl <[email protected]>
Translate client-auth outcomes into a closed UI-facing recovery vocabulary so
the TUI can request enrollment only for actionable local credential states and
keep server or transport failures distinct.

Co-Authored-By: mecatl <[email protected]>
…ures

Render non-secret saved-target authentication state and emit a restart intent
for reauthorization. This lets the UI guide recovery without handling OAuth
material or embedding browser behavior.

Co-Authored-By: mecatl <[email protected]>
Connect the target-bound credential lifecycle to mecatui commands and remote
connection setup so users can enroll, refresh, revoke locally, and reauthorize
saved targets through one supervised flow.

Co-Authored-By: mecatl <[email protected]>
Exercise the extracted HTTPS client against the supported private issuer and
DNS behaviors so its reuse preserves the existing OIDC transport contract.

Co-Authored-By: mecatl <[email protected]>
Add fixture coverage for the remote OIDC setup so the documented Kind path
proves its registered client, issuer trust, and caller-identity prerequisites.

Co-Authored-By: mecatl <[email protected]>
Describe enrollment, saved-target operation, and logout behavior so operators
can configure remote mecatui authentication and understand its local
credential lifecycle.

Co-Authored-By: mecatl <[email protected]>
Allow the fixture client to request offline access when supported so the
remote-login walkthrough can exercise refresh-token behavior without making
that scope mandatory for every provider.

Co-Authored-By: mecatl <[email protected]>
Document the provider scopes, grants, and client configuration required for
mecatui to refresh a saved remote credential rather than unexpectedly asking
users to log in again.

Co-Authored-By: mecatl <[email protected]>
Provide a reproducible Kind and Keycloak walkthrough that provisions the
issuer, client, trust material, and target needed to validate remote mecatui
login end to end.

Co-Authored-By: mecatl <[email protected]>
Grant the optional offline-access role to fixture users so the quickstart can
actually obtain a refresh token after the client is allowed to request it.

Co-Authored-By: mecatl <[email protected]>
Ignore a malformed persisted connection while retaining valid saved targets
and rejecting invalid new writes. One legacy row should not make every remote
target unavailable after an upgrade.

Co-Authored-By: mecatl <[email protected]>
Route the walkthrough through a service hostname rather than localhost so
mecatui treats the target as remote and does not send its local workspace to a
server that owns its own workspace.

Co-Authored-By: mecatl <[email protected]>
Reuse the already validated scoped client and extend the operation budget so
macOS cluster.local resolution stalls do not exhaust logout before discovery
and revocation. Preserve the safe provider failure cause for diagnosis.

Co-Authored-By: mecatl <[email protected]>
Use literal equality for the single supported fixed callback URI and remove
the duplicate absent-issuer test. Parsing fields already implied by equality
added no protection or coverage.

Co-Authored-By: mecatl <[email protected]>
Remove the one-consumer optional storage capability and invoke atomic corrupt
repair only through the encrypted file store that owns its record lock. This
keeps the recovery guarantee without presenting it as a general backend port.

Co-Authored-By: mecatl <[email protected]>
…reuse

RefreshSource.tokenLocked already decides a refresh is due (via its own
refreshAhead window) before it ever calls oauth2.TokenSource.Token(). But
that call was seeded with the token's real (not-yet-expired-by-x/oauth2's
own smaller reuse threshold) expiry, so TokenSource could hand back the
locally-constructed placeholder token verbatim without touching the network.
That placeholder never had TokenType set, so the follow-up Save() rejected
it as "corrupt credential" -- a false alarm on every refresh attempt that
lands in the ~20s window between mecatl's and x/oauth2's two different
staleness thresholds, self-healing only once the token crossed x/oauth2's
own cutoff. The stored credential was never actually touched or corrupted.

Seed TokenSource with an already-past Expiry so it always performs a real
refresh_token exchange once our own gate has decided one is warranted.

Found via a live Kind+Keycloak fixture qualification run (shortened token
lifespans) exercising sustained active use across repeated access-token
expiries.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Co-Authored-By: mecatl <[email protected]>
Document the 15-second operation-wide remote logout provider budget, including why cluster.local DNS resolution needs it while local logout remains independent.

Co-Authored-By: mecatl <[email protected]>
@jhrozek
jhrozek force-pushed the split/mecatui-remote-login branch from e2d8583 to dd243c1 Compare August 29, 2026 22:13
@JAORMX

JAORMX commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

I did a full panel review of this one, including the security, architecture, Kubernetes, DevOps, UX, and reuse angles. I also compared the storage model with ToolHive and toolhive-core.

The fundamentals are good. Local remote-OIDC credentials use a random 256-bit wrapping key in the OS keyring plus an owner-only AES-256-GCM file store. This is the right local model and matches ToolHive's encrypted provider. The intended Kubernetes topology is also correct: mecatui owns the caller credential, while mecak8s only validates bearer identity and does not instantiate the desktop keyring or clientauth store.

I don't think this is ready to merge yet, though. I found four blockers:

  1. authn/oidc/scopedhttps/client.go:44 enables keep-alives, but accepted ADR 0235 explicitly requires them disabled so every request goes through DNS re-resolution and the approved-address intersection. The transport wrapper also does not expose CloseIdleConnections, and RefreshSource.Close never closes that pool. We should either restore DisableKeepAlives: true, or make this an explicit superseding decision and wire transport cleanup.

  2. internal/adapter/clientauth/store.go:647 silently filters invalid registry entries. Upsert and DeleteTarget later rewrite that filtered projection (store.go:727 and store.go:770). Updating target B can therefore erase malformed/legacy target A metadata and strand A's credential. The current test proves bad rows do not block unrelated reads, but it does not prove they survive unrelated writes.

  3. The root module is not tidy. GOWORK=off go mod tidy -diff requires updates to x/tools, x/mod, and go-openapi/swag. This is the direct cause of the red Kubernetes job under GOFLAGS=-mod=readonly; the suite never starts.

  4. deploy/mecak8s-vmcp/README.md:122 tells users to request --audience mecatui-kind, while the Keycloak mapper at deploy/mecak8s-vmcp/keycloak.yaml:352 issues http://127.0.0.1:18080/mcp. The documented login fails token validation.

A few other things are worth fixing in the same pass:

  • cmd/mecatui/main.go:714 uses OpenStore during saved-target connect. That can create a new keyring key during a read-only connection attempt. OpenExistingStore is the correct path.
  • internal/adapter/clientauth/oidc.go:336-374 validates a newly refreshed access token before saving a rotated refresh token. A temporary JWKS outage after a successful rotation can discard the only valid refresh token. Save the rotation with CAS before returning the availability error, but do not serve the access token until validation succeeds.
  • cmd/mecatui/login.go:123-148 checks keyring/store availability only after the browser flow. A locked keyring makes the user complete login before learning that the result cannot be saved.
  • The --no-browser SSH guidance is incomplete. The callback is fixed at 127.0.0.1:18473, so opening the URL on another machine requires an SSH forward or the callback goes to the wrong host.
  • Keyring/corrupt-store failures are mapped back into "sign in again" even though another browser login may not repair them (cmd/mecatui/ui/connect.go:208-233). We should preserve a safe local-failure category and give an actionable recovery instead of creating a login loop.
  • The Keycloak fixture should set automountServiceAccountToken: false (deploy/mecak8s-kind/keycloak.yaml:499).

On the Kubernetes question: the current local-client to remote-mecak8s topology does not put desktop credentials in the pod, which is good. If we want the OIDC client itself to run as a normal Kubernetes workload, that path is still missing. The lifecycle depends on the concrete file-backed Registry and target flocks, so the existing memory/environment credential stores cannot compose the whole flow. ToolHive keeps this boundary explicit: local CLI uses keyring-backed encrypted storage, stateless use can use an environment provider, Kubernetes uses native Secret references, and ephemeral DCR has an explicit closeable in-memory store. I would track a workload token-source/in-memory composition separately rather than making browser login or a desktop keyring work inside a pod.

Verification from a clean worktree:

  • task lint passed.
  • Root, UI, engine, provider, clientauth, credentialstore, oauthlogin, and scoped-HTTPS race tests passed locally.
  • The CI-failing TestClearBuiltinProgram passed locally, including repeated targeted runs, so that failure looks flaky. It still needs a green rerun.
  • task test later hit the existing authn/oidc standalone hygiene failure where fixture_test.go imports internal/adapter/server; that file is outside this PR's diff.
  • GOWORK=off go mod tidy -diff failed and reproduced the Kubernetes CI blocker.
  • go run ./cmd/mecademo passed.

So... good security work and a solid local custody model, but the four blockers above should be addressed before merge.

Fixes the four blockers plus minor findings from the panel review on the
remote OIDC login PR:

- ADR 0250 supersedes ADR 0235's keep-alive policy: scopedhttps now allows
  a small bounded connection pool instead of disabling keep-alives outright,
  since dialContext already re-validates every new connection against the
  approved address set. RefreshSource/Login now release idle connections on
  close/failure via a plumbed-through CloseIdleConnections.
- clientauth Registry now preserves unparseable/invalid saved-connection
  rows verbatim (raw JSON) across Upsert/DeleteTarget/replaceTarget instead
  of silently dropping them when rewriting the file for an unrelated target.
- go.mod/go.sum tidied (x/tools, x/mod, go-openapi/swag bumps) to fix the
  GOWORK=off tidy check the k8s e2e job depends on.
- deploy/mecak8s-vmcp docs now request the audience the Keycloak mapper
  actually issues, plus real --no-browser SSH port-forward guidance.
- Saved-target connect/login paths use OpenExistingRegistry/
  NewExistingKeyringProvider/OpenExistingStore so a read-only connection
  attempt can no longer create new keyring/registry state.
- RefreshSource persists a rotated refresh token before validating the new
  access token, so a transient JWKS outage can no longer strand a one-time
  refresh token.
- automountServiceAccountToken: false on the Keycloak fixture deployments.
- Local failures that reauthentication cannot fix (keyring/registry/
  encrypted-store unavailable, unreachable issuer/CA) now route to a
  distinct AuthStorageUnavailable recovery reason instead of collapsing
  into "sign in again" and looping.

Also fixes over-engineering flagged in review of the fix itself: the
namespace-directory hash naming scheme was reimplemented byte-for-byte in
clientauth instead of reusing credentialstore's (now exported as
NamespacePhysicalName); the keyring account-name hash was duplicated
between the new and existing-only constructors (factored into
keyringAccountFor); and AuthCredentialCorrupt/AuthIssuerUnavailable added
no new routing behaviour over AuthCredentialUnusable/AuthStorageUnavailable
(dropped, merging into those two).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek

jhrozek commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review — pushed a fix commit (16ede81) addressing all four blockers plus the minor findings:

  1. Keep-alive vs ADR 0235 — went with the explicit-superseding-decision option: new ADR 0250 documents a small bounded connection pool (MaxIdleConns=8, per-host=2, 30s idle timeout), since dialContext already re-validates every new connection against the approved address set. scopedTransport now exposes CloseIdleConnections, and RefreshSource/Login release the pool on close/failure when they own the client.
  2. Registry data loss — Upsert/DeleteTarget/replaceTarget now carry invalid/unparseable rows through as raw JSON instead of dropping them when rewriting the file for an unrelated target.
  3. Tidy — go.mod/go.sum bumped (x/tools, x/mod, go-openapi/swag/*) to match GOWORK=off go mod tidy -diff.
  4. Audience mismatch — README now requests the audience the Keycloak mapper actually issues, plus real --no-browser SSH port-forward guidance instead of the incomplete note.

Minor items also addressed:

  • Saved-target connect/login now goes through OpenExistingRegistry/NewExistingKeyringProvider/OpenExistingStore so a read-only connection attempt can't create new keyring/registry state.
  • RefreshSource now persists a rotated refresh token before validating the new access token, so a transient JWKS outage can't strand a one-time refresh token.
  • automountServiceAccountToken: false added to both Keycloak fixtures.
  • Local failures reauth can't fix (keyring/registry/store unavailable, unreachable issuer/CA) now route to a distinct AuthStorageUnavailable recovery reason instead of collapsing into "sign in again" and looping.

I also ran a self-review of the fix pass for over-engineering before committing: the namespace-directory hash naming was reimplemented byte-for-byte in clientauth instead of reusing credentialstore's (now exported as NamespacePhysicalName), the keyring account-name hash was duplicated between two constructors (factored into keyringAccountFor), and an initial draft added three new AuthReason values where two produced no new routing behavior over the others — collapsed back to one new reason (AuthStorageUnavailable).

task lint && task test are green (the one remaining failure, authn/oidc's standalone fixture_test.go importing internal/adapter/server, is the pre-existing hygiene issue you flagged as outside this PR's diff).

On the Kubernetes-workload OIDC client question — agreed, tracking that separately rather than folding it into this PR.

jhrozek and others added 2 commits August 30, 2026 21:27
The prior merge commit renamed the incoming ADR 0244 (full-request
accounting/manual compaction) to 0251 to resolve the number collision
with this branch's own ADR 0244 (remote mecatui OIDC), but the doc-cross-
reference updates and the regenerated llms.txt were only made in the
working tree after the merge commit's index was already staged, so they
never made it into that commit. This finishes staging them: two stale
`./0244-full-request-and-manual-compaction.md` links, the unreachable/
under-linked warnings on the renamed file, and llms.txt drift.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
jhrozek and others added 2 commits August 31, 2026 11:22
…login

# Conflicts:
#	cmd/mecatui/client/client.go
#	cmd/mecatui/main.go
#	llms.txt
- Saved-target reauthentication now opens only existing keyring/store
  state (NewExistingKeyringProvider/OpenExistingStore) instead of the
  creating path, so a missing keyring entry can no longer look like
  corruption and get silently replaced. Regression tests cover both
  the login path and the store's existing-only open.
- vMCP walkthrough now requests --scopes explicitly (incl.
  offline_access) and the fixture Keycloak realm grants the
  offline_access scope/role so the documented command actually
  receives a refresh token.
- The registry-unavailable connect screen no longer offers "Sign in to
  a new target..." (it needs the same registry that just failed to
  load), closing the reauth loop.
- Re-merged origin/main (status-line feature, goccy-yaml migration,
  safe build diagnostics) and resolved the resulting conflicts in the
  gRPC client (bearer token source wiring) and cmd/mecatui/main.go
  (ui.Deps field set), renumbered the remote-login ADRs to 0252-0258
  to clear the collision with main's newly added ADRs, and
  regenerated llms.txt.
- Minor cleanup from the review: PrivateHTTPS now rejects a supplied
  HTTPClient instead of silently ignoring it, legacyCredentialExists
  reuses credentialstore.NamespacePhysicalName instead of duplicating
  the hash protocol, the existing-only store contract moved into the
  credentialstore adapter (OpenExistingEncryptedFile), unused
  registryFile/Registry.write removed, and the two identical
  ErrDiscovery branches in main.go collapsed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek

jhrozek commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — pushed a fix commit (c1d3701b5) addressing all four blockers plus the cleanup items:

  1. Saved-target reauth still creating state — cmd/mecatui/login.go now has a dedicated prepareExistingSavedRemoteLogin/runExistingSavedRemoteLogin path that only calls NewExistingKeyringProvider/OpenExistingStore, never the creating constructors. Added TestExistingSavedRemoteLoginMissingStoreDoesNotLaunchBrowserOrCreateState plus store-level regression tests (TestOpenExistingStoreMissingKeyLeavesCiphertextUntouched, TestOpenExistingStoreDoesNotRepairExistingDirectoryModes) proving a missing key neither creates a replacement nor touches the existing ciphertext/permissions.

  2. vMCP walkthrough scopes/offline_access — the README command now requests --scopes openid,profile,mcp:read,offline_access explicitly, and the Keycloak fixture grants offline_access as both an optional client scope on mecatui-kind and a realm role assigned to both fixture users, so the documented command actually gets a refresh token.

  3. Registry-unavailable enrollment loop — cmd/mecatui/ui/connect.go now tracks targetsUnavailable and hides the "Sign in to a new target..." row (and blocks all key input) whenever the saved-targets load failed, so a broken registry can no longer be routed back into itself.

  4. Merge conflicts with main — re-merged origin/main (status-line feature, goccy-yaml migration, safe-build-diagnostics) and hand-resolved the semantic conflicts in cmd/mecatui/client/client.go (kept both bearerBacked/IsNotFound and the new displayServerEndpoint diagnostics) and cmd/mecatui/main.go (ui.Deps gained fields from both sides), renumbered the branch's ADRs to 0252–0258 to clear a fresh collision with main's newly-added ADRs, and regenerated llms.txt. Note: main has kept moving since (it just picked up 3 more commits), so llms.txt will need one more mechanical regen at actual merge time — that's just the generated index drifting, not a real content conflict.

Smaller cleanup items:

  • oidcClient now rejects a PrivateHTTPS+supplied-HTTPClient combination up front instead of silently ignoring the custom client, with regression tests on both Login and NewRefreshSource proving no request is sent.
  • legacyCredentialExists now calls credentialstore.NamespacePhysicalName instead of duplicating the hash protocol.
  • The existing-only open contract moved into the credential-store adapter (credentialstore.OpenExistingEncryptedFile, with unix-side validateExistingPrivateRoot/validateExistingPrivateDir helpers that only Lstat, never create); OpenExistingStore is now a thin caller. Regression test TestOpenExistingEncryptedFileLeavesRootAndNamespaceUntouched covers it.
  • Removed the unused registryFile/Registry.write.
  • Collapsed the two identical ErrDiscovery branches in main.go.

Verification from a clean worktree: go build ./..., targeted go vet/golangci-lint and go test over the touched packages (cmd/mecatui/..., internal/adapter/clientauth/..., internal/adapter/credentialstore/..., internal/adapter/store/jsonlstore/..., internal/deploycheck/...) all green, GOWORK=off go mod tidy -diff clean, task docs:check clean, and go run ./cmd/mecademo still prints a full offline session.

jhrozek and others added 3 commits August 31, 2026 11:39
…login

# Conflicts:
#	cmd/mecatui/ui/update.go
#	llms.txt
The rename from 0251-full-request-and-manual-compaction.md to
0259-full-request-and-manual-compaction.md was staged via git mv before
the header text was corrected, so the commit shipped the renamed file
with its stale "ADR 0251" title while llms.txt (generated from the
already-corrected working tree) said "ADR 0259" — a mismatch the docs
CI job caught.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@JAORMX JAORMX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix pass. Most of the previous findings are now addressed, including the vMCP scopes/audience, malformed-row preservation, refresh-token ordering, bounded keep-alives, existing-only credential-store constructor, and the merge/doc regeneration.

There are still a few blockers in the integrated path:

  1. Saved-target reauthentication is still wired to the creating path. restartFromConnectIntent injects runSavedRemoteLogin at cmd/mecatui/main.go:492-498, so the Reauthenticate action reaches NewKeyringProvider and OpenStore through cmd/mecatui/login.go:107-130. A missing key can still mint a replacement and make the old ciphertext look corrupt. The new runExistingSavedRemoteLogin exists, but production does not call it. Note that swapping the function directly is not enough: OpenExistingRegistry leaves Registry.lock nil (internal/adapter/clientauth/store.go:693-715), while successful enrollment reaches replaceTarget and dereferences that lock (store.go:933-939). We need a non-creating preflight followed by an intentional mutation-capable transaction, plus a regression test through the real restartFromConnectIntent wiring.

  2. Logout still creates or migrates state. cmd/mecatui/logout.go:38-49 uses OpenRegistry and NewKeyringProvider before opening the existing store. That can create the config root/lock and migrate legacy keyring state during an idempotent destructive operation. The absent-state path should stay non-creating.

  3. Logout does not reuse the scoped HTTPS client across the operation. internal/adapter/clientauth/logout.go:143-180 constructs and closes one client per retained credential, even though ADR 0257 requires one operation-wide client so later discovery/revocation requests do not repeat first-dial DNS validation.

  4. Provider-controlled revocation URLs can reach the UI. A client.Do failure retains the request URL (internal/adapter/clientauth/logout.go:315-318), recordRevocationError stores the raw error (logout.go:189-195), and cmd/mecatui/logout.go:88-92 prints it. ADR 0252 explicitly excludes provider-controlled discovery endpoint values from errors, diagnostics, and UI state. Sanitize at the provider-error boundary.

  5. Discovery classification is still collapsed. Both branches at cmd/mecatui/main.go:784-792 return AuthStorageUnavailable, and cmd/mecatui/login.go:208-213 maps every ErrDiscovery the same way. Generic issuer status/format/network failures are not local storage failures, and ADR 0252 says unknown discovery/infrastructure failures remain unclassified.

The panel also found some recovery UX gaps, especially headless reauthentication hard-coding browser launch (cmd/mecatui/main.go:540-542) and private-CA settings not following a switch to a different saved target. Those should be covered while fixing the production recovery flow rather than leaving another retry loop.

So, not quite ready to approve yet. The current CI is green except for the two root race shards still running; the latest 73149fa23 docs-only commit fixed the ADR 0259 header failure but does not change the blockers above.

jhrozek and others added 3 commits August 31, 2026 12:43
MoE-verified findings from JAORMX's latest review (5 confirmed blockers,
1 confirmed UX gap, 1 refuted as working-as-designed):

1. Saved-target reauthentication now actually wires
   runExistingSavedRemoteLogin in production (restartFromConnectIntent
   was still calling the creating runSavedRemoteLogin). OpenExistingRegistry
   now populates a real but inert *flock.Flock in both branches so a
   successful reauth's write-back (Enroll -> replaceTarget) no longer
   nil-pointer panics; a write against a genuinely-missing root still
   fails cleanly instead of creating anything.
2. mecatui logout now opens the registry/keyring via the existing-only
   constructors instead of the creating ones, and Logout short-circuits
   to a clean zero-entry result when the registry root was never created
   (lockTarget would otherwise ENOENT on a directory that doesn't exist).
3. Logout builds ONE scoped HTTPS client for the whole operation (merged
   endpoints/CA across every retained connection) instead of rebuilding
   one per credential, matching ADR 0258's bounded-keep-alive intent.
4. Revocation errors are now sanitized before being recorded/printed: a
   raw *url.Error's embedded request URL (provider-controlled, from OIDC
   discovery) never reaches LogoutResult.RevocationError or the CLI
   output; only a closed, harness-authored category does.
5. clientauth.ErrDiscovery (issuer unreachable/untrusted TLS/JWKS failure)
   no longer gets mapped to AuthStorageUnavailable in main.go/login.go --
   it now falls through to AuthFailure's deliberate "remain unclassified"
   case instead of steering the user toward a local-storage reset that
   can't fix a network problem.
6. A Reauthenticate restart now threads the process's own headless
   detection (ConnectRestartIntent.NoBrowser, sourced the same way as
   NoBanner's non-interactive-stdin check) into the login call instead
   of hardcoding a browser-launch attempt.

Regression tests added for each: production-wiring pin (function-pointer
comparison), nil-lock write-through-existing-registry, logout-of-never-
created-root no-op, shared-client-single-build + no-renewed-deadline,
revocation-error URL-leak, discovery-classification, and headless-restart
threading.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek

jhrozek commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks — ran a MoE-style verification pass on all 5 blockers + 2 panel findings from the last review (independent fresh-context agents adversarially re-checked each claim against the current code before I touched anything), then pushed a fix commit (c459c037c, re-merged since with main).

Confirmed and fixed (5 blockers + 1 UX gap):

  1. Reauth still wired to the creating path — restartFromConnectIntent was still calling runSavedRemoteLogin instead of runExistingSavedRemoteLogin; fixed. Also confirmed and fixed the deeper issue: OpenExistingRegistry left lock == nil, so a successful existing-only reauth would nil-pointer-panic in replaceTarget. OpenExistingRegistry now populates a real but inert *flock.Flock in both branches (constructing one does no I/O until Lock()/TryLock(), so the no-create guarantee holds — a write against a genuinely-missing root still fails cleanly via writeRows's os.CreateTemp). Added TestDefaultConnectRestartOpsUsesExistingOnlyReauthLogin (pins the wiring) and TestOpenExistingRegistryCanCompleteAWriteWhenRootExists/WriteFailsCleanlyWhenRootMissing.

  2. Logout still creates state — cmd/mecatui/logout.go now uses OpenExistingRegistry/NewExistingKeyringProvider. Also found and fixed an additional gap the verification turned up: Registry.lockTarget (called by Logout before any existence check) would ENOENT against a root that was never created. Logout now short-circuits to a clean zero-entry result in that case. TestLogoutOfNeverCreatedRegistryIsACleanNoOp.

  3. Logout rebuilds an HTTPS client per credential — confirmed, with a real wrinkle the verification surfaced: retained credentials can be on different issuers/CAs (the existing duplicateLogoutState test fixture already covers this). Fixed by building ONE client for the whole operation from the union of every retained connection's issuer + CA, matching ADR 0258's bounded-keep-alive intent. TestLogoutSharedClientServesEveryEntryUnderOneBudget replaces the old per-entry-construction test (whose premise no longer applies).

  4. Raw revocation error can leak a provider-controlled URL — confirmed direct hit against ADR 0252. Added sanitizeRevocationError (modeled on the existing safeValidationError) that classifies into a closed, URL-free category before recordRevocationError stores it; the issuer prefix stays (operator-configured, not provider-controlled). TestRevocationErrorNeverLeaksProviderEndpointURL drives a real *url.Error (connection-refused) through it.

  5. ErrDiscovery misclassified as AuthStorageUnavailable — confirmed, and shown to be user-visibly wrong (drives the "reset local storage" recovery copy for what's actually a network/TLS/JWKS problem). Both call sites (main.go, login.go) now let it fall through to AuthFailure's deliberate "remain unclassified" case instead. TestSigninErrorLeavesDiscoveryFailuresUnclassified.

  6. Headless reauth hardcodes browser launch — confirmed. Added ConnectRestartIntent.NoBrowser / ui.Deps.NoBrowser, sourced from the same non-interactive-stdin detection NoBanner already uses, threaded into the Reauthenticate restart's login call. TestReauthenticateRestartHonorsHeadlessIntent.

Refuted (no change): the private-CA-not-following-target-switch item — the transport CA (--tls-ca flag only) and the OIDC CA (Connection.IssuerCAFile, correctly target-scoped) are two independent things by design; the sameTarget gate on the transport CA is correct.

CI is fully green on the latest push (86c4d31a6, re-merged with main — a docs-only commit, llms.txt regenerated). go build, targeted go vet/golangci-lint/go test on every touched package, go mod tidy -diff, and task docs:check all clean locally too.

@JAORMX JAORMX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the third fix pass. The production reauthentication wiring, existing-only logout open, URL sanitization, and operation-wide cleanup budget are now in place. The panel still found a few blockers in the new integrated behavior:

  1. The shared logout client unions unrelated issuer CA roots. cmd/mecatui/logout.go:62-79 concatenates every retained connection's CA bundle, and authn/oidc/scopedhttps/client.go:40-63 installs that union for every approved endpoint. A CA configured only for issuer A can therefore authenticate issuer B. Since revocation POSTs carry the still-valid access/refresh token, this is a cross-issuer credential exposure if that CA and B's route/DNS are compromised. Keep one operation-wide budget/client lifecycle, but select roots per approved issuer endpoint. The security and architecture reviewers independently confirmed this.

  2. Existing-target reauthentication does not preserve the identity precondition across the browser flow. cmd/mecatui/login.go:173-212 preflights one saved connection, but generic Enroll takes a fresh snapshot and replaces whatever exists when the flow finishes (internal/adapter/clientauth/enroll.go:44-87). A concurrent logout can be resurrected, or a newer enrollment can be overwritten and its credential deleted. ADR 0258 allows this recovery only while its transaction and identity preconditions hold. The commit needs an expected-connection/CAS-style reauth write-back, with tests for concurrent logout and replacement enrollment.

  3. Discovery is still misclassified during refresh. cmd/mecatui/auth.go:35-40 maps any ErrDiscovery to AuthStorageUnavailable, even though ADR 0252 says unknown discovery/infrastructure errors remain unclassified. The startup and login mappings were fixed, but this third path still sends users toward local-storage remediation for an issuer/network failure.

  4. Recovery is not consistently browser-free as ADR 0258 requires. Interactive reauthentication may still pass NoBrowser=false through cmd/mecatui/ui/connect.go:148-150 and cmd/mecatui/main.go:547-553. Also, runDisconnectedRecovery does not carry NoBrowser into its ui.Deps at cmd/mecatui/main.go:461-466, so a non-interactive startup failure loses the posture entirely. The new propagation test accepts both booleans rather than pinning the browser-free recovery contract.

  5. The batch client ownership path regressed cleanup on partial construction. If HTTPClientOwned returns (client, true, err), internal/adapter/clientauth/logout.go:179-196 returns without closing the owned client's idle connections. The previous implementation handled this shape. Please restore cleanup and add the direct regression test.

  6. The vMCP walkthrough still names root tasks that do not exist or operate on the wrong fixture. deploy/mecak8s-vmcp/README.md:47-50 uses task mecak8s:vmcp-*, but the root Taskfile.yml:18-24 includes only deploy/mecak8s-kind/Taskfile.yml; task --dry mecak8s:vmcp-check fails. The documented mecak8s:kind-hosts-add also installs the mecatl.svc.cluster.local aliases, not the required mecatl-vmcp.svc.cluster.local aliases shown at README.md:89-94. Now that this PR claims the remote-login walkthrough is runnable, those commands need to reach the vMCP Taskfile explicitly.

Reuse/duplication found no unnecessary abstraction. Targeted tests for cmd/mecatui/..., internal/adapter/clientauth/..., and authn/oidc/... pass, and current CI is green. These are behavioral and trust-boundary gaps that the existing tests do not cover, so I cannot approve this head yet.

MoE-verified findings from JAORMX's latest review (5 confirmed, 1 fixed
directly on read):

1. scopedhttps.NewClient no longer unions every approved endpoint's CA
   into one shared RootCAs pool -- a cross-issuer credential exposure
   where issuer A's CA could authenticate a connection to issuer B.
   It now takes a map[endpoint][]byte and performs the TLS handshake
   itself via DialTLSContext, verifying each connection against ONLY
   that endpoint's own CA pool (VerifyConnection + a per-host
   x509.CertPool). Existing single-issuer callers use the new
   NewSingleIssuerClient convenience wrapper. Regression test drives
   an actual forged cert (signed by endpoint A's CA) against endpoint
   B and confirms it's rejected -- the exact shape the old union bug
   would have accepted.
2. Reauthentication now closes the TOCTOU gap between its preflight
   (before the interactive browser OAuth exchange, which can run
   arbitrarily long) and Enroll's write-back: EnrollmentConfig gained
   ExpectedTarget (registry-level) and ExpectedCredential
   (credential-version-level) preconditions, checked under the same
   target lock the eventual write uses. A concurrent logout or a
   newer enrollment for the same target during that wait now surfaces
   as ErrTargetChanged -> a new AuthTargetChanged recovery reason,
   instead of being silently resurrected or clobbered. Two regression
   tests cover both races directly.
3. A third ErrDiscovery-to-AuthStorageUnavailable misclassification
   site (cmd/mecatui/auth.go's per-RPC token-refresh path) fixed the
   same way as the two already addressed: falls through to
   AuthFailure's unclassified case instead of steering toward a
   local-storage reset that can't fix a network problem.
4. runDisconnectedRecovery now computes its own headless posture
   (the same non-interactive-stdin signal used elsewhere) instead of
   defaulting ui.Deps.NoBrowser to false -- a non-interactive startup
   failure was losing the posture entirely. (The interactive-path
   complaint in the same finding was investigated and found to already
   be correct as designed.)
5. Logout's owned-client cleanup no longer leaks idle connections when
   the shared client builder returns a partially-constructed client
   alongside an error.
6. The vMCP walkthrough's task commands now resolve: added a
   mecak8s-vmcp: Taskfile include (the vmcp fixture's tasks collide by
   name with the kind fixture's, so they need their own namespace) and
   fixed the two places the vmcp Taskfile itself called back into the
   wrong namespace. README updated to match.

Additional fix found during self-review: the per-issuer CA map in
cmd/mecatui/logout.go now unions CA bytes instead of overwriting when
two retained connections share an issuer with different CA files, and
prepareExistingSavedRemoteLogin canonicalizes its target comparison
defensively rather than trusting the caller.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@JAORMX JAORMX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fourth fix pass. The vMCP task namespace now resolves to the right fixture, refresh discovery is no longer classified as a storage failure, and the partial-client cleanup is restored. The expected-state work also closes the healthy-credential logout and re-enrollment races.

There are still three blockers:

  1. The logout CA pools are isolated by hostname, not endpoint authority. authn/oidc/scopedhttps/client.go:136-145 merges roots for every URL sharing a hostname, while the approved connection is keyed by host and port. Two issuers on issuer.example:8443 and issuer.example:9443 therefore share roots. A CA configured only for the first issuer can authenticate the second, and revocation sends live access and refresh tokens over that connection. The new regression test uses different hostnames, so it misses this case. Key roots by the same canonical host:port authority used by approvedEndpoint, and add the same-host/different-port test.

  2. Corrupt-credential reauthentication still drops the credential precondition. cmd/mecatui/login.go:170-179 deliberately leaves ExpectedCredential nil after ErrCorrupt. If another process repairs or re-enrolls that same identity while the OAuth flow is open, Enroll takes a fresh healthy snapshot and overwrites the newer credential because checkExpectedCredential has no constraint (internal/adapter/clientauth/enroll.go:67-74, :112-120). The expected-state type needs to represent "was corrupt" explicitly. At commit time, require that it is still corrupt and route a healthy replacement to ErrTargetChanged. The same check should reject a newly corrupt current record when the preflight expected a concrete healthy version.

  3. Recovery can still open a browser. ADR 0254 says the recovery overlay "never opens a browser," and ADR 0258 defines browser-free retry as the existing login ADDRESS --no-browser flow. Instead, cmd/mecatui/ui/connect.go:148-150 copies m.deps.NoBrowser, which is false for an interactive terminal, and cmd/mecatui/main.go:553-557 passes that through to login. The test at cmd/mecatui/connect_test.go:259-293 accepts both values, so it preserves the mismatch instead of pinning the contract. Reauthentication from the recovery overlay should always set NoBrowser=true.

One smaller docs issue is worth fixing in this pass: the new runnable vMCP login example still uses <mecak8s-host>, <fixture-https-issuer>, and <exported-fixture-ca> at deploy/mecak8s-vmcp/README.md:122-132, even though the exact host, issuer, and generated CA path are already known in the same document. Using those concrete values would make the promised walkthrough copy-pasteable.

I verified the previous task-routing finding with task --dry: mecak8s-vmcp:vmcp-check, kind-hosts-add, and vmcp-setup now expand through the vMCP Taskfile. CI is green on 15b55ac0c. Reuse and duplication found no unnecessary abstraction, but the two transaction/trust-boundary gaps and the documented recovery mismatch still need changes before approval.

MoE-verified findings from JAORMX's latest review (3 blockers + 1 docs
issue, all confirmed by independent fresh-context review agents):

1. scopedhttps's CA-pool isolation was keyed by hostname only, not the
   full host:port authority -- two different issuers sharing a
   hostname on different ports would share one merged CA pool. Now
   keyed by the same host:port authority approvedEndpoint already
   uses. New test drives a forged cert through the exact same-host/
   different-port shape.
2. The reauthentication CAS precondition had a gap for corrupt
   credentials: ExpectedCredential was left nil after a corrupt
   preflight read, so a healthy repair landing during the browser wait
   could still be clobbered. ExpectedCredentialState gained a Corrupt
   field; the repair path now only proceeds if the record is STILL
   corrupt at commit time, and a current record that's corrupt when a
   healthy/absent state was expected is also rejected. New test covers
   the repaired-during-corrupt-signin race.
3. The recovery overlay's Reauthenticate action now always sets
   NoBrowser=true (ADR 0254: the overlay never opens a browser),
   instead of deriving it from the process's own interactive/headless
   posture. Since that was NoBrowser's only reader, the now-dead
   ui.Deps.NoBrowser field and its two setters were removed. New test
   pins the always-true contract against the real UI method; the
   existing lower-level plumbing test's stale doc comment was
   corrected to describe what it actually covers.
4. The vMCP login walkthrough now uses concrete, copy-pasteable
   values (host, issuer, exported CA path) instead of placeholders.

Independent fresh-context verification of finding 3 raised a genuine
disagreement worth recording: reading ADR 0254 fresh, it reached the
same conclusion as an earlier review round -- "never opens a browser"
more plausibly describes the overlay's own display step than a mandate
covering every subsequent reauthentication -- and flagged a real UX
cost (an interactive user no longer gets an automatic browser launch).
Implemented anyway per the reviewer's explicit, twice-stated directive
to avoid another review cycle; flagging here for visibility.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@JAORMX

JAORMX commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

I pulled 94bb789df and checked the fifth fix pass. The CA pool now uses the same canonical host:port authority as endpoint admission, including a same-host/different-port regression test. Corrupt preflight state is represented explicitly and rejects a credential that was repaired while OAuth was in progress. The UI now emits browser-free recovery, and the vMCP command uses concrete values.

There is one smaller invariant issue left in the browser-free fix. ConnectRestartIntent still represents Reauthenticate and NoBrowser independently (cmd/mecatui/ui/connect.go:43-56), and the composition boundary still trusts the boolean at cmd/mecatui/main.go:544-550. So Reauthenticate{NoBrowser:false} remains valid program state even though the field comment says it is always true, and the plumbing test deliberately accepts both values. The current UI producer does the right thing, but another producer or a later refactor can still reopen the browser path.

I would remove NoBrowser from ConnectRestartIntent and pass true unconditionally in the Reauthenticate branch. The action already carries the full policy decision, so a second boolean only creates an invalid combination.

Other than that, this pass looks clean. I did not rerun CI locally; GitHub does not report checks for 94bb789df yet.

@JAORMX

JAORMX commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

I pulled the new head (307d6750f). This update only merges the latest main; it does not address the remaining Reauthenticate + NoBrowser:false state. ConnectRestartIntent.NoBrowser still exists and restartFromConnectIntentWith still passes it through at cmd/mecatui/main.go:544-550. The action should own that policy and call login with true unconditionally.

The merge also left the OIDC ADR renumbering inconsistent. The files moved to 0270–0277, but their titles and cross-references still use the old 0253–0260 numbers. For example:

  • docs/adr/0270-activity-gated-remote-oidc-refresh.md:1,7,67
  • docs/adr/0271-tui-reauth-owner-recovery.md:1,7,49-50
  • docs/adr/0274-remote-mecatui-logout-budget.md:1,6,39
  • docs/adr/0275-bounded-scoped-https-keepalive-oidc.md:1,6,62-63
  • docs/adr/0277-remote-mecatui-oidc.md:1,6-7
  • docs/adr/README.md:52 labels the new ADR 0253 as 0270.

Several links still point to files that no longer exist, such as ./0256-remote-mecatui-oidc-login.md and ./0260-remote-mecatui-oidc.md. Code comments also still cite ADR 0254/0258/0252 after those decisions moved to 0271/0275/0277. Please update the ADR headers, metadata, links, README entries, and code citations as one consistent mapping, then regenerate llms.txt rather than hand-editing it.

CI is still in progress on this merge head; the docs jobs have not started yet.

… boundary

Also finishes the ADR 0253-0260 -> 0270-0277 renumber (main claimed those
numbers with unrelated ADRs): commits the doc-body number/cross-reference
fixes that were staged as part of the rename but not yet edited when the
merge commit landed.

A boolean field on ConnectRestartIntent that "is always true, per ADR 0254"
was still representable as false, and the plumbing test accepted both
values -- so a future producer or refactor could reopen the browser path
for reauthentication. Removed the field; restartFromConnectIntentWith now
passes true unconditionally for the Reauthenticate branch, so the ADR 0254
contract (recovery overlay never opens a browser) can't be violated by any
producer of the intent.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek

jhrozek commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the fifth pass, and sorry for the delay picking it up.

Fixed the remaining invariant issue: removed NoBrowser from ConnectRestartIntent entirely (cmd/mecatui/ui/connect.go) rather than just defaulting it to true. restartFromConnectIntentWith's Reauthenticate branch now passes true to the login call unconditionally (cmd/mecatui/main.go:549), so ADR 0254's "never opens a browser" contract can no longer be represented as false by any producer of the intent, current or future. Updated the two tests that exercised the old field (cmd/mecatui/connect_test.go, cmd/mecatui/ui/connect_test.go) to match.

Also finished committing the ADR 0253-0260 -> 0270-0277 renumber from the merge with main (main had independently claimed 0252/0253 for its own unrelated ADRs) -- the rename was staged but a few doc-body number/cross-reference edits hadn't landed in the merge commit; those are included now.

go build, go vet, golangci-lint, go test ./cmd/mecatui/..., and task docs:check all pass locally on 43f054101.

@JAORMX

JAORMX commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

The behavioral fix is correct now: NoBrowser is gone from ConnectRestartIntent, and the Reauthenticate branch enforces true at the composition boundary with a direct regression test.

The ADR file bodies are mostly renumbered, but a few stale references remain:

  • docs/adr/README.md:52 labels the new SDK mocking ADR as 0270, but its file/header is ADR 0253.
  • docs/adr/README.md:63 says ADR 0277 supersedes 0253–0256; that should be 0270–0273.
  • docs/adr/README.md:65-68 still says those records were superseded by 0260; the replacement is 0277.
  • docs/adr/0277-remote-mecatui-oidc.md:7 lists only ADR 0274 as superseding it, while ADR 0275 also supersedes its credential-recovery classification.
  • Code/test comments still cite the old numbers: ADR 0254 should be 0271 in cmd/mecatui/main.go, cmd/mecatui/connect_test.go, and cmd/mecatui/ui/connect_test.go; ADR 0258 should be 0275 in cmd/mecatui/logout.go; ADR 0252 should be 0277 in internal/adapter/clientauth/logout.go and store_test.go.

The implementation is clean from this pass. Once those remaining references are made consistent, I have no further findings. CI is still running on 43f054101.

The earlier batch renumber's blanket "[0253 --" replace also hit the
unrelated line pointing at main's own ADR 0253-sdk-mocking-testkit.md,
restored to its real number. Fixes README's supersedes/superseded-by
number ranges (0253-0256 -> 0270-0273, "superseded by 0260" -> 0277), adds
the missing ADR 0275 credential-recovery-classification supersession to
0277's header, and updates the remaining stale ADR-number code/test
comments (0254->0271, 0258->0275, 0252->0277).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek

jhrozek commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks -- fixed all five items:

  • docs/adr/README.md:52 restored to ADR 0253 (that line was pointing at main's own unrelated SDK-mocking ADR; my earlier batch renumber's blanket bracket replace wrongly caught it).
  • docs/adr/README.md:63 now says "supersedes 0270-0273".
  • docs/adr/README.md:65-68 now say "superseded by 0277".
  • docs/adr/0277-remote-mecatui-oidc.md:7 now lists both ADR 0274 (logout provider budget only) and ADR 0275 (credential-recovery classification only) as superseding it.
  • Stale code/test comment numbers fixed: ADR 0254->0271 in cmd/mecatui/main.go, cmd/mecatui/connect_test.go, cmd/mecatui/ui/connect_test.go; ADR 0258->0275 in cmd/mecatui/logout.go; ADR 0252->0277 in internal/adapter/clientauth/logout.go and store_test.go.

task docs:check, go build, go vet, and golangci-lint all pass on 20d9a6052. Also confirming CI came back fully green on the prior commit (43f054101).

@JAORMX JAORMX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ADR renumber cleanup is complete, the post-43f054101 changes are limited to that cleanup, and all current-head CI checks are green.

@jhrozek
jhrozek merged commit 007a8c8 into main Aug 31, 2026
39 of 41 checks passed
@jhrozek
jhrozek deleted the split/mecatui-remote-login branch August 31, 2026 18:28
reyortiz3 added a commit that referenced this pull request Sep 23, 2026
Addresses the 2026-09-23 review round:

- Document the /oauth/callback redirect_uri registration requirement for
  preregistered/CIMD clients in user-docs (AGENTS.md requires this in the
  same PR as the behavior change).
- Fix a comment in cmd/mecated/mcplogin.go that referenced opts.Client.DCR
  on a local oauthlogin.Options value that has no Client field; the DCR
  field actually lives on the unrelated mcp.OAuthOptions built in
  internal/cliconfig/mcpprofile.go.
- Add TestRunMCPLoginProductionOptionsKeepDCRPriorityThroughRealRuntime: an
  app-wiring-layer test that captures the real production
  oauthlogin.Options, obtains a genuine registration-bound callback path
  from mcp.PrepareOAuthDCRLogin against a real DCR fixture, and drives both
  through a real oauthlogin.Runtime -- proving the priority holds beyond
  the isolated mcp/oauthlogin package.
- Replace the port-distinctness assertion in
  TestPinCallbackPathUsesFixedPathEphemeralPort (flaky if the OS legally
  reuses a just-released ephemeral port) with an assertion on the bind
  address requested via the injected listener seam.
- Extract assertUnauthenticatedFloodDoesNotSpendAttempts, shared by
  TestExactRedirectUnauthenticatedFloodDoesNotSpendAttempts and
  TestPinCallbackPathUnauthenticatedFloodDoesNotSpendAttempts, which had
  drifted into a near-duplicate.
- Return a callbackMode struct from resolveCallbackMode instead of five
  positional string/enum values, matching the file's existing
  fixedRedirectConfig convention and removing a silent-reorder risk.
- Extract exactRedirectAddress so "127.0.0.1:18473" has one source instead
  of three duplicated literals that must stay byte-identical.

Two other findings from the same review round were pushed back on with
reasoning posted to the PR rather than implemented:
- The "CIMD cannot work with this mode" blocker: CIMD is a public/native
  client mechanism by design and by this codebase's own config schema (no
  secret field), so RFC 8252 loopback matching applies to a CIMD-declared
  redirect_uri the same as it does to a preregistered one.
- The "needs a superseding ADR" claim: two prior PRs (#847, #1388) already
  added new fixed-callback Options fields to this exact runtime without a
  superseding ADR, establishing that this is within-mechanism extension,
  not an architectural decision.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

Remote mecatui OIDC login: enrolment, refresh, recovery, and logout

2 participants