Repository navigation
feat: complete provider setup UX on unified configuration - #1441
Conversation
Feedback: converge provider configuration and the Mecatui provider CLIThe newly added This proposal standardizes on provider in both configuration and CLI. Desired domain modelA provider is a named source of models used by a Mecatl deployment. Every provider has:
The user should select a provider name, not decide whether it is a "native endpoint," an API endpoint, or an integration. Provider classes
Transport origin (stock or custom) and authentication are independent dimensions. A provider's integration advertises its supported authentication methods; its configuration selects exactly one active method. This permits a provider such as a corporate gateway to support both API-key and OIDC setups without inventing two user-facing provider types. OIDC is an authentication mode, not a separate kind of user-facing LLM or endpoint.
Configuration directionStandardize on the existing operator-owned Conceptually, a custom OIDC provider should be expressible alongside an API-key provider: The final field layout should respect existing validation and custody boundaries, but the configuration must describe one provider record rather than split a provider's transport data under Compatibility and migration
Use provider name everywhere in CLI copy, help, errors, and documentation. Reserve URL for the configured network address. Do not call a provider name an "endpoint." Proposed CLIRename the primary command group to Exact verbs can be refined, but the action should be selected by provider capability:
The existing Help and guidance requirementsEvery listed command and subcommand needs a real
|
jhrozek
left a comment
There was a problem hiding this comment.
Panel review complete (Spec, Standards, Test adequacy, Domain: secure-code-reviewer, go-architect, library-reuse-reviewer, code-duplication-reviewer). No ship-blockers.
Approving for velocity. The findings below (6 important, several advisory — inline comments to follow) are flagged for visibility; addressing them is at the author's discretion, not a condition of this approval.
🤖 Generated with Claude Code
jhrozek
left a comment
There was a problem hiding this comment.
Panel review findings (Spec/Standards/Test-adequacy/Domain, 7 agents, no ship-blockers). Posted here for visibility per the panel review — addressing any of these is at the author's discretion, not a condition of the approval already given.
🤖 Generated with Claude Code
| if err != nil { | ||
| return false | ||
| } | ||
| uid, ok := ownerUID(info) |
There was a problem hiding this comment.
[important] ownerUID (line 266, a few lines below sameParent — unchanged by this diff but exercised by the new re-verification path here) can nil-pointer-panic
func ownerUID(info os.FileInfo) (uint32, bool) {
stat, ok := info.Sys().(*syscall.Stat_t)
return stat.Uid, ok
}
stat.Uid is dereferenced regardless of ok. If the assertion fails, stat is a nil *syscall.Stat_t and this panics instead of returning false — both call sites (readTarget, and sameParent right here) rely on the ok bool and would otherwise fail closed safely. The sibling fileIdentity a few lines below guards this correctly. Suggested fix:
| uid, ok := ownerUID(info) | |
| func ownerUID(info os.FileInfo) (uint32, bool) { | |
| stat, ok := info.Sys().(*syscall.Stat_t) | |
| if !ok { | |
| return 0, false | |
| } | |
| return stat.Uid, true | |
| } |
Pre-existing (not introduced by this diff), but this PR's new TOCTOU re-verification calls through sameParent more heavily, so flagging now.
(go-architect, domain axis)
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| var testHook func(string) error |
There was a problem hiding this comment.
[advisory] package-global mutable test hook
testHook is global state inside the commit path of a security-critical writer. Idiomatic-enough Go for fault injection, but it means tests touching this package can't run with independent hooks in parallel. Not blocking — just flagging the tradeoff.
(go-architect, domain axis)
| @@ -202,12 +329,22 @@ func (c providerCommands) oidcStatus(ctx context.Context, definition permconfig. | |||
|
|
|||
| func builtinProviderStatuses(keys cliconfig.ResolvedCredentials, shadowed map[string]bool) []providerStatus { | |||
There was a problem hiding this comment.
[important] builtin-provider facts duplicated across 6 sites
builtinProviderStatuses here, the known slice and shadowed/sources map construction in inspectLocalProviders, isBuiltinAPIKeyProvider in provider_credential.go, and the guidance switch in writeProviderKeyGuidance all separately encode "which providers are builtin." Adding a 6th builtin provider means 6 edits — miss the shadowed/sources one and the status output silently mis-reports provenance, which is exactly what this status flow exists to get right.
Suggested direction: one package-level table of {id, defaultModel, envKey func(ResolvedCredentials) string, guidance string} that the 5-6 call sites range over instead of re-enumerating the provider list. cliconfig's own known-provider list is unexported so it can't be reused directly across the package boundary — this would need its own local table.
(go-architect, domain axis)
| invalid = true | ||
| continue | ||
| } | ||
| if len(line) == 8*1024 || tooLong { |
There was a problem hiding this comment.
[advisory] 8 KiB bound hardcoded in two places
Same literal (8*1024) appears here and in validateProviderAPIKey (provider_credential.go:180). Worth a shared const so the two never drift.
(go-architect, domain axis)
| // cancellation. The duplicate shares flags with stdin, so restore those too. | ||
| // | ||
| //nolint:gocyclo // Keep terminal cleanup, bounded polling, and the small byte-editing state machine together. | ||
| func readProviderTerminalLine(ctx context.Context, input, output *os.File, prompt string, hidden bool) (value string, err error) { |
There was a problem hiding this comment.
[advisory] hand-rolled raw-mode reader is justified, but undocumented as such
This reimplements a cancellable, size-bounded, UTF-8-validating line reader with backspace editing on top of x/term.MakeRaw/Restore plus manual unix.Poll/unix.Read. It's not gratuitous — x/term.ReadPassword has no ctx-cancellation, no size bound, and no non-hidden echo-with-editing mode, so there's no single stdlib/x/term call that replaces this. A short comment naming that ceiling (why ReadPassword doesn't suffice) would stop a future reader from "simplifying" this back into losing ctx cancellation or the 8 KiB bound.
(library-reuse-reviewer, domain axis)
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| func providerPTYName(t *testing.T, fd int) string { |
There was a problem hiding this comment.
[important] hand-rolled PTY opener — github.com/creack/pty already does this
This file (and its Linux sibling) reimplements grantpt/unlockpt/ptsname via raw TIOCPTYGRANT/TIOCPTYUNLK/TIOCPTYGNAME (darwin) / TIOCSPTLCK/TIOCGPTN (linux) ioctls plus a manual /dev/ptmx open, purely for a test fixture. github.com/creack/pty (BSD-3, no CGo, de-facto standard for Go PTY test harnesses — used by Docker, gliderlabs/ssh, etc.) does the same thing via one pty.Open() call. Test-only dependency, no runtime surface added; would replace both platform files and net roughly -35 lines, and removes a per-OS raw-ioctl surface that's easy to get subtly wrong.
(library-reuse-reviewer, domain axis)
| return sp, ap | ||
| } | ||
|
|
||
| func TestProviderSetupFollowup_Scenario1_StatusProvenance(t *testing.T) { |
There was a problem hiding this comment.
[important, test adequacy] AC1.1's named test doesn't exercise malformed/unreadable credential input
TestProviderSetupFollowup_Scenario1_StatusProvenance only covers "present" vs. "removed" credential state, but AC1.1 explicitly requires that missing/malformed/unreadable input are "not conflated" — and provider_status.go (providerCredentialInputError) has three distinct branches for exactly that. The distinction is tested, but under a differently-named test (TestProviderFollowupStatusInputFailures in provider_followup_consent_test.go), so a regression collapsing those branches wouldn't fail the AC's own cited verify test. Given task ac-trace-strict traces by test name, worth either renaming/merging or adding the assertion here.
(test-adequacy axis)
| } | ||
| } | ||
|
|
||
| func TestProviderSetupFollowup_Scenario2_ReuseAndIndependentConsent(t *testing.T) { |
There was a problem hiding this comment.
[important, test adequacy] AC2.2's named test never drives a successful replace-and-write
Both the "reuse" and "replace" sub-cases in TestProviderSetupFollowup_Scenario2_ReuseAndIndependentConsent answer "no" to the save confirmation — the test could pass even if the shared writer were broken or never invoked on a consented replace. Two other AC2.2 requirements (the "environment credential will still win" warning, and blank/oversized-key rejection) are also unasserted here, covered only by uncited sibling tests (TestProviderFollowupReplacementShadowWarning, TestProviderFollowupConsentStages). Same traceability gap as above.
(test-adequacy axis)
| } | ||
| }) | ||
| } | ||
| for _, args := range [][]string{{"llm", "status"}, {"providers", "login", "openai", "--api-key-file", "key"}, {"providers", "setup", "--auth-file", "key"}} { |
There was a problem hiding this comment.
[important, test adequacy] AC4.3 legacy-grammar rejection checked by 3 hardcoded invocations, not the registered command tree
This loop ({"llm","status"}, --api-key-file, --auth-file) proves those three specific spellings are rejected, but doesn't enumerate the actual registered flag/command surface — a legacy artifact surviving under an untested spelling wouldn't be caught. Lifecycle behavior itself (add/login chain, --no-login, logout, remove) in this same test is solid.
(test-adequacy axis)
Follow-up simplification passThis update keeps the provider-setup scope but removes complexity that was not carrying its weight:
Deferred deliberately: the broader settings-plus-auth provider snapshot design, the OpenRouter Validation after the latest changes: |
71e2637 to
6835ca6
Compare
6835ca6 to
81161f9
Compare
Co-Authored-By: mecatl <[email protected]>
Add cancellable Linux/macOS hidden terminal input, explicit credential reuse and save/default consent, passive effective-source reporting, and manual Codex reuse through shared validation. Preserve add/logout/remove lifecycle semantics and repair flow-style settings writes and empty credential residue. Cover the eleven follow-up acceptance criteria, including real PTY cleanup, signal exit, oversized input, and command-route regression tests. Update the owning user guidance; keep the plan in progress pending review. Co-Authored-By: mecatl <[email protected]>
Complete setup-only custom-provider default selection and preserve committed state across cancellation and ambiguous default writes. Permit consented first enrollment into an absent configured key file without weakening passive status or malformed-input rejection. Keep OIDC cancellation truthful when its credential directory or remote state may remain. Preserve safe terminal diagnostics and EOF cancellation, publish actionable manual-platform and Codex guidance, and cover real PTY echo and commit states. Run provider PTY regressions in the existing native macOS CI gate. Co-Authored-By: mecatl <[email protected]>
Handle replacement_applied_durability_unknown before generic errors or cancellation. Direct users to passive status and configured-file inspection before manual retry without exposing backend errors or claiming rollback. Exercise direct login, stock/custom setup and add through the actual command seams with applied writes, sync faults, cancellation and not-applied controls. Keep possibly active keys and saved definitions; stop before optional defaults. Co-Authored-By: mecatl <[email protected]>
Enumerate descriptor names without Darwin's failing directory-entry stat. Handle partial PTY writes and EAGAIN under bounded polling so oversized input reaches the real reader without weakening its acceptance assertions. The draft coverage failure was an unrelated fixture race: blockingChunks can emit its entire finite response before the client sends Cancel. Use a provider that yields the first delta then waits for context cancellation. Keep the wire-level cancelled-result assertion and production code intact. CI evidence: run 34832113603 at 65b6dd4. Focused Linux tests pass with and without race detection; lint passes. Native macOS execution remains a required post-push check. Co-Authored-By: mecatl <[email protected]>
Report only numeric before/after flags and syscall errors for the native Darwin restoration assertion uncovered after the PTY fixture repairs. Co-Authored-By: mecatl <[email protected]>
Native diagnostics showed only FWASWRITTEN (0x10000) changed: 0x2 to 0x10002, or 0x6 to 0x10006 for nonblocking input. Prime and drain the shared output descriptor before taking the baseline, preserving exact flag equality and every restoration assertion without masking bits or changing production. Co-Authored-By: mecatl <[email protected]>
CI run 34835086868 passed native Darwin but exposed the baseline promoted-relay fixture: turn.end precedes steer closure. Wait for the existing terminal outcome before sending the late steer, and keep its relay parked within the unchanged 20-second test budget. Full local race suites also exposed the credential helper fixture racing process startup against its stall deadline. Keep the 100ms stall/deadline assertions; give only exit-status cases time to start. No production, cancellation, gate selection or assertion changes. Co-Authored-By: mecatl <[email protected]>
Co-Authored-By: Mecatl <[email protected]>
Co-Authored-By: Mecatl <[email protected]>
Co-Authored-By: Mecatl <[email protected]>
Co-Authored-By: Mecatl <[email protected]>
81161f9 to
9799536
Compare
Draft implementation — rebuilt on unified configuration
This is the actual follow-up implementation on merged #1448 / ADR 0333, not the old prototype port. Existing Plan / Interface PR #1440 remains the base and human contract gate.
dc793b57b95eeb9c3823b2d8356d2bb65f3c96d2.9b15e85b768cd55084c311c5611820b7c801228f(plan/mecatui-local-provider-setup).fdbd369c50c804ee391457a666d7471f53ec6069(feat: unify provider configuration and Mecatui commands #1448). Remote main has since advanced tod25313767befc803277e38d658193844d6d150ab; no new main merge was performed.31df424bfef87169f430b8bf710ebc06a597af55through preserved merges. The reconciliation merge reset the implementation tree to the revised plan before residual work; obsolete prototype history is superseded, not replayed. Old tips remain archived/in ancestry. No rebase, force push, or cleanup.Delivered scope
replacement_applied_durability_unknownbefore generic API-key errors/cancellation: the key change may already be active and crash durability is uncertain; inspect named passive status and the configured credential file before manual retry. Direct login, stock/custom setup and add tests inject the actual write followed by unknown outcomes, including cancellation and secret-bearing faults. No blind deletion, retry, false rollback, leaked fault/path, or later default mutation; saved custom definitions remain. The already-correct ambiguous-default branch is unchanged.user-docs/features/choose-models.mdanduser-docs/mecatui/getting-started.md.No new command family, config schema, credential custody/store, public engine API, locks, cooperative retry protocol, or universal POSIX CAS guarantee. No automatic setup/startup, legacy
llm/--auth-fileforms, Codex enrollment/refresh/import, forced replacement-default selection, or changed selected-default removal policy. Add normally chains login; logout is credential-only; removal remains combined and does not select a replacement.Eleven-AC trace
Own-plan strict trace reports 11 ACs / 11 test-verified / 0 missing. The current native macOS job also passed the real PTY/provider regressions and private-file writer suites; see the CI repair evidence below.
TestProviderSetupFollowup_Scenario1_StatusProvenanceTestProviderSetupFollowup_Scenario1_RuntimeCredentialParityTestProviderSetupFollowup_Scenario1_PassiveBoundariesTestProviderSetupFollowup_Scenario2_ConsoleAndCustodyGuidanceTestProviderSetupFollowup_Scenario2_ReuseAndIndependentConsentTestInvariant_ProviderSetupFollowup_TerminalCancellationAndSecretSafetyTestProviderSetupFollowup_Scenario3_CodexLoaderAndReuseTestProviderSetupFollowup_Scenario3_SharedDefaultResolutionTestProviderSetupFollowup_Scenario4_PortablePrivateFileBoundaryTestProviderSetupFollowup_Scenario4_TruthfulWriteOutcomes; final real-routeTestProviderReviewAPIKeyWriteOutcomeTestProviderSetupFollowup_Scenario4_UnifiedLifecyclePreservedVerification before CI repair (
65b6dd4a)These are the previously recorded feature gates. The subsequent CI repair and current-head verification are recorded below; docs, schema and production code are unchanged by that repair.
go test -race ./cmd/mecatuiprovider review/follow-up/PTY/consent/add-cancellation selection-count=1).task linttask testtask docs/task site:buildtask api:checkgo run ./cmd/mecademoactrace --strict --plan docs/acceptance/mecatui-local-provider-setup.mdtask ac-trace-strictdocs/acceptance/callmcpwithquery-broker-support.mdstatusproposed(tool exit 2). This unrelated baseline plan/tool mismatch was reproduced, not suppressed; neither old plan nor pin was changed.git diff --no-ext-diff --no-textconv --checkand ancestrytask buildand Darwin/FreeBSD compile-only checks also passed at independently reviewed parenta4fd6317f16c9c518e0c884757ac24b77f17b5b3; the final repair changes only the credential outcome branch and its route tests. No live provider calls were made. Local process-only signing/GOMAXPROCS/GOFLAGS settings were used, with no global host changes.CI repair on the current head
The failures were investigated from the exact failed-job logs at
65b6dd4a, CI run 34832113603, not blindly rerun:TestGRPCConverseCancelreturnedend_turn. Its baselineblockingChunksfixture is a finite response, not a blocking stream; the transport can finish before the Cancel frame. The test now yields one delta then waits for context cancellation. The separateTest (non-race draft)failure was only the aggregate dependency check.TestInvariant_ProviderSetupFollowup_TerminalCancellationAndSecretSafetyfailed withfstatat /dev/fd: bad file descriptor. Enumerate names without implicitly statting Darwin descriptor-directory entries, retaining explicit descriptor matching/leak assertions.TestProviderReviewTerminalCommandErrors/oversizedfailed withEAGAIN. The fixture now preserves partial writes and polls under bounded PTY backpressure so the entire oversized input reaches the real reader.0x2 → 0x10002(nonblocking:0x6 → 0x10006), Darwin's kernel-maintainedFWASWRITTENbit—not failedO_NONBLOCKrestoration. Prime and drain the fixture's shared output descriptor before its flag snapshot. Exact flag equality is retained; no masking, platform skips or production change. Native PTY/provider/writer execution passed at79fb608aain job 103947035526.TestSteer_PromotedRelaySequentialtimed out atsteer_handoff_test.go:349. Itsturn.endobservation precedes steer-inbox closure; it now waits for the existing terminal outcome signal before sending the late steer. Its relay stays parked within the unchanged 20-second total test budget. All promotion, multimodal echo, ordered-stream and EOF assertions remain.TestHeadlessCredentialStorage_Scenario1_HelperFailuresFailClosedraced a race-instrumented helper's startup against a 100ms deadline in exit-status cases. Only those cases get startup allowance; the actual stall and explicit deadline tests retain their original 100ms budgets and every assertion. No production deadline or cancellation change.These repairs change only four test files, with no new dependency/API/schema/CLI/lock protocol or workflow-gate changes. Normal pushes only; all commits have Co-Authored-By trailers. No agents were delegated during this repair.
Current-head checks: all applicable checks passed, monitored to completion, including CI run 34836108990, both draft test checks, native macOS PTY/provider/writer execution, perf, k8s e2e and Vercel. Existing draft race-shard/live-job skips are unchanged; they were not used to replace native execution.
Local final-head gates also passed:
task lint, fulltask test(root + engine + OIDC + provider race suites and all standalone proofs), and the complete offlinego run ./cmd/mecademosession. Focused cancellation and promoted-relay tests each passed x100 non-race + x100 race; provider review/PTY tests passed x10 non-race + x1 race; helper exit/deadline tests passed x20 race.Local verification uses process-only signing overrides (a host
tag.gpgsign=trueotherwise launched an editor in an unrelated SDK release fixture),GOMAXPROCS=4, andGOFLAGS=-p=2; no global host setting was changed. Docs/site/plan trace were not rerun for this test-only repair; their prior evidence and the global strict-trace blocker above remain accurately attributed to the earlier feature head.Independent review closure and remaining gates
The supplied independent panel has no open Spec, Standards, Test adequacy, Domain/security, Architecture, UX, or DevOps findings after the final AC4.2 red/green proof. One low duplication advisory is consciously retained: the two loader paths do not justify premature extraction. Positive informational reuse comments are not counted as findings. No additional panel was run during this final repair/publication step.
PANEL ship_blockers=0 important=0 advisory=1 reviewer_failures=0CI monitoring is complete and green on the current head. Global strict trace and human plan/code merge gates remain outstanding, so this PR remains draft. No new panel was run for these test-only CI repairs. The implementation worktree is clean; no main merge, force push or cleanup was performed. Detailed local run evidence is retained under ignored
.scratch/orchestrate/pr1441-ci-fix/final-publication.md.Tracking: Plan / Interface PR #1440. No issue-closing relationship.