Skip to content

Refactor Claude provider planning foundations#494

Open
ratulsarna wants to merge 12 commits intomainfrom
rat-110-claude-source-planner-consolidation
Open

Refactor Claude provider planning foundations#494
ratulsarna wants to merge 12 commits intomainfrom
rat-110-claude-source-planner-consolidation

Conversation

@ratulsarna
Copy link
Collaborator

@ratulsarna ratulsarna commented Mar 7, 2026

Summary

This PR carries the first Claude provider refactor stack.

The main goal is to reduce Claude-provider sprawl without changing product expectations. Source planning now comes from a shared planner, plan inference and credential routing are normalized earlier at the boundaries, and the current behavior contract is characterized and documented.

Main implementation areas

  • Added characterization coverage and current-state docs for Claude behavior.
  • Centralized Claude plan inference and compatibility handling.
  • Normalized Claude credential routing for app and CLI entry points.
  • Introduced a shared ClaudeSourcePlanner and aligned descriptor, direct fetcher, debug diagnostics, and fetch-attempt reporting around it.
  • Preserved parse-dump behavior while moving planner diagnostics onto the Claude debug-log surface.

Residual notes

  • This is an intentionally stacked PR and includes the first four Claude refactor slices together.
  • Future Claude refactor work should branch from this stack until it merges.
  • The direct ClaudeUsageFetcher(.auto) path now follows planner availability strictly. That removes the older final OAuth fallback after CLI failure, which was previously inconsistent with the declared availability probe and is now intentionally gone.

@ratulsarna ratulsarna force-pushed the rat-110-claude-source-planner-consolidation branch from a82e4f1 to 9565254 Compare March 8, 2026 10:33
@ratulsarna
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 95652546a9

ℹ️ 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".


func isAvailable(_ context: ProviderFetchContext) async -> Bool {
_ = context
return self.plannedStep.isPlausiblyAvailable

Choose a reason for hiding this comment

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

P2 Badge Do not gate explicit CLI fetches on planner availability

Returning plannedStep.isPlausiblyAvailable from ClaudePlannedFetchStrategy.isAvailable means explicit .cli mode is skipped whenever the preflight CLI probe says unavailable, so ProviderFetchPipeline never calls ClaudeCLIFetchStrategy.fetch and instead returns ProviderFetchError.noAvailableStrategy. That is a behavior regression from the previous explicit CLI path (which attempted the fetch and surfaced concrete CLI/probe errors), and it conflicts with the planner contract where explicit modes execute ordered steps regardless of availability (executionSteps is not filtered for explicit selections).

Useful? React with 👍 / 👎.

…based on source mode; add test for CLI strategy availability when planner marks it as unavailable.
@ratulsarna
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: f357d48aa2

ℹ️ 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 on lines +142 to +145
if let override = environment["CLAUDE_CLI_PATH"]?.trimmingCharacters(in: .whitespacesAndNewlines),
!override.isEmpty
{
return FileManager.default.isExecutableFile(atPath: override) ? override : nil

Choose a reason for hiding this comment

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

P2 Badge Fall back to PATH when CLAUDE_CLI_PATH is invalid

When CLAUDE_CLI_PATH is set but points to a non-executable path, this branch returns nil immediately, so Claude CLI discovery stops instead of falling back to normal lookup. In environments with a stale override and a valid claude on PATH, auto planning and fetches will now incorrectly treat CLI as unavailable. This is a regression from the prior resolver path that continued through BinaryLocator/PATH-based discovery.

Useful? React with 👍 / 👎.

Comment on lines +782 to +785
if binaryName.contains("/") {
return binaryName
}
return ClaudeCLIResolver.resolvedBinaryPath(environment: environment)

Choose a reason for hiding this comment

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

P3 Badge Preserve custom binary command names in status probe

This resolver now ignores non-path binaryName values (for example "claude-beta") and always resolves the default Claude binary, so callers that pass an alternate command name can no longer target that executable. As a result, ClaudeStatusProbe(claudeBinary: ...) may run the wrong binary unless the argument is an absolute/relative path containing /.

Useful? React with 👍 / 👎.

@ratulsarna
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ 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".

@ratulsarna ratulsarna marked this pull request as ready for review March 8, 2026 13:11
# Conflicts:
#	Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthDelegatedRefreshCoordinator.swift
#	Tests/CodexBarTests/ClaudeOAuthDelegatedRefreshCoordinatorTests.swift
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.

1 participant