Skip to content

Improve Codex branding and prompt fetch resilience#30

Merged
riatzukiza merged 3 commits intostagingfrom
chore/handle-missing-codex-prompt-warming
Nov 19, 2025
Merged

Improve Codex branding and prompt fetch resilience#30
riatzukiza merged 3 commits intostagingfrom
chore/handle-missing-codex-prompt-warming

Conversation

@riatzukiza
Copy link
Copy Markdown
Collaborator

Summary

  • add gpt-5.1-codex-max support with config/docs/tests and persistent rolling logging
  • rename the plugin identity to openhax/codex and align log prefixes
  • make OpenCode codex prompt fetch resilient with dev/main fallbacks and cached source metadata

Testing

  • npm test -- test/prompts-opencode-codex.test.ts test/prompts-codex.test.ts test/logger.test.ts test/auth.test.ts test/constants.test.ts

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 19, 2025

Warning

Rate limit exceeded

@riatzukiza has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between d1f8207 and a98014d.

⛔ Files ignored due to path filters (6)
  • docs/configuration.md is excluded by none and included by none
  • docs/development/ARCHITECTURE.md is excluded by none and included by none
  • docs/development/TESTING.md is excluded by none and included by none
  • spec/handle-missing-codex-prompt-warming.md is excluded by none and included by none
  • spec/opencode-prompt-cache-404.md is excluded by none and included by none
  • spec/plugin-name-rename.md is excluded by none and included by none
📒 Files selected for processing (9)
  • lib/constants.ts (1 hunks)
  • lib/logger.ts (1 hunks)
  • lib/prompts/opencode-codex.ts (2 hunks)
  • lib/request/response-handler.ts (2 hunks)
  • test/auth.test.ts (7 hunks)
  • test/constants.test.ts (1 hunks)
  • test/logger.test.ts (3 hunks)
  • test/prompts-codex.test.ts (2 hunks)
  • test/prompts-opencode-codex.test.ts (1 hunks)

Summary by CodeRabbit

  • New Features

    • Added multi-URL fallback mechanism for improved data fetch reliability and robustness.
  • Bug Fixes

    • Fixed inconsistent logging behavior across different environments.
    • Enhanced error handling with improved cache fallback support.
  • Chores

    • Updated plugin identification throughout the system.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

The PR renames the plugin identifier from "openai-codex-plugin" to "openhax/codex" throughout the codebase. It modifies the logger to suppress logs uniformly when logging is disabled, removing a prior test-environment exception. It introduces multi-URL fetch with per-URL fallback logic for OpenCode codex prompts, supporting conditional requests and aggregated error handling.

Changes

Cohort / File(s) Summary
Plugin Identifier Refactoring
lib/constants.ts, lib/request/response-handler.ts
Updated PLUGIN_NAME constant from "openai-codex-plugin" to "openhax/codex" and adjusted corresponding error message strings.
Logger Control Flow
lib/logger.ts
Removed test-environment exception from logToConsole guard; now suppresses logging uniformly when shouldLog is false, independent of IS_TEST_ENV.
OpenCode Codex Multi-URL Fallback
lib/prompts/opencode-codex.ts
Introduced iterative fetching over multiple GitHub URLs with per-URL conditional requests (If-None-Match), per-URL cache tracking, and consolidated error handling with fallback to cached content. Extended OpenCodeCacheMeta interface to include optional sourceUrl field.
Test: Constants & Logger
test/constants.test.ts, test/logger.test.ts, test/auth.test.ts, test/prompts-codex.test.ts
Updated test expectations to reflect new plugin name "openhax/codex" in logged error prefixes and constant assertions.
Test: OpenCode Codex Fallback Logic
test/prompts-opencode-codex.test.ts
Normalized string literals to double quotes; added test scenarios for URL fallback on fetch failure, cache directory creation, and metadata edge cases (missing etag, malformed metadata); adjusted assertions and control flow to match new multi-URL behavior.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant Logger
    participant Console
    
    rect rgb(240, 248, 255)
    Note over Logger: OLD BEHAVIOR
    App->>Logger: logToConsole(msg, shouldLog=false)
    alt IS_TEST_ENV = true
        Logger-->>App: (returns early, logs suppressed)
    else IS_TEST_ENV = false
        Logger->>Console: write(msg)
    end
    end
    
    rect rgb(240, 245, 240)
    Note over Logger: NEW BEHAVIOR
    App->>Logger: logToConsole(msg, shouldLog=false)
    alt shouldLog = false
        Logger-->>App: (returns early, logs always suppressed)
    else shouldLog = true
        Logger->>Console: write(msg)
    end
    end
Loading
sequenceDiagram
    participant Caller
    participant OpenCodeFetch
    participant GitHubURL1
    participant GitHubURL2
    participant Cache
    
    Caller->>OpenCodeFetch: fetch codex content
    
    rect rgb(240, 248, 255)
    Note over OpenCodeFetch: Iterate URLs
    OpenCodeFetch->>GitHubURL1: GET with If-None-Match (etag from cache)
    
    alt 200 OK
        GitHubURL1-->>OpenCodeFetch: new content
        OpenCodeFetch->>Cache: write content + sourceUrl + timestamps
        OpenCodeFetch-->>Caller: return content
    else 304 Not Modified
        OpenCodeFetch->>Cache: fetch cached content
        OpenCodeFetch-->>Caller: return cached content
    else fetch fails or non-OK
        OpenCodeFetch->>GitHubURL2: retry with next URL
        alt 200 OK
            GitHubURL2-->>OpenCodeFetch: new content
            OpenCodeFetch->>Cache: write content + sourceUrl
            OpenCodeFetch-->>Caller: return content
        else all URLs exhausted
            OpenCodeFetch->>Cache: try fallback to any cached content
            alt cache exists
                OpenCodeFetch-->>Caller: return cached content (log error)
            else no cache
                OpenCodeFetch-->>Caller: throw aggregated error
            end
        end
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Areas requiring extra attention:

  • lib/logger.ts: The removal of test-environment exception may alter logging behavior in test suites across the system. Verify that existing tests do not rely on logs being emitted during test runs.
  • lib/prompts/opencode-codex.ts: The multi-URL fallback and per-URL conditional request logic (If-None-Match scoping, sourceUrl tracking, error aggregation) introduces moderate complexity. Pay close attention to edge cases: cache initialization, missing etag values, malformed metadata, and the order/priority of fallback URLs.
  • test/prompts-opencode-codex.test.ts: Verify that new test scenarios (404 fallback, missing etag, malformed metadata) have correct expectations and mock setups, particularly around cache directory creation and metadata assertions.

Possibly related PRs

Poem

🔌 From Codex to Hax, the name takes flight,
URLs multiplied for fallback might,
Logs now honest in every scene,
The logger's dual life finally unseen.
openhax/codex in bold ascent! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: rebranding to 'openhax/codex' and improving prompt fetch reliability with fallbacks and caching.
Description check ✅ Passed The description provides relevant context covering the three main objectives: model support, plugin rebranding, and prompt fetch resilience. It also specifies test commands for verification.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca55057 and d1f8207.

⛔ Files ignored due to path filters (6)
  • docs/configuration.md is excluded by none and included by none
  • docs/development/ARCHITECTURE.md is excluded by none and included by none
  • docs/development/TESTING.md is excluded by none and included by none
  • spec/handle-missing-codex-prompt-warming.md is excluded by none and included by none
  • spec/opencode-prompt-cache-404.md is excluded by none and included by none
  • spec/plugin-name-rename.md is excluded by none and included by none
📒 Files selected for processing (9)
  • lib/constants.ts (1 hunks)
  • lib/logger.ts (1 hunks)
  • lib/prompts/opencode-codex.ts (2 hunks)
  • lib/request/response-handler.ts (1 hunks)
  • test/auth.test.ts (7 hunks)
  • test/constants.test.ts (1 hunks)
  • test/logger.test.ts (3 hunks)
  • test/prompts-codex.test.ts (2 hunks)
  • test/prompts-opencode-codex.test.ts (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
test/constants.test.ts (1)
lib/constants.ts (1)
  • PLUGIN_NAME (7-7)
test/prompts-opencode-codex.test.ts (2)
lib/cache/session-cache.ts (1)
  • openCodePromptCache (77-77)
lib/prompts/opencode-codex.ts (2)
  • getOpenCodeCodexPrompt (34-132)
  • getCachedPromptPrefix (139-149)
lib/prompts/opencode-codex.ts (2)
lib/cache/session-cache.ts (1)
  • openCodePromptCache (77-77)
lib/logger.ts (1)
  • logError (100-102)
🔇 Additional comments (8)
lib/constants.ts (1)

7-7: Plugin identity rename looks correct

PLUGIN_NAME now matches the new openhax/codex branding and stays consistent with logger usage and tests; no further changes needed here.

test/auth.test.ts (1)

202-315: Auth logging expectations align with new prefix

The updated console.error expectations correctly reflect the [openhax/codex] prefix and preserve the existing payload formats and failure semantics for auth flows. No issues from the test side.

test/logger.test.ts (1)

102-180: Logger console prefix tests match runtime behavior

The updated expectations for logWarn and overflow/persist warnings correctly reflect the [openhax/codex] prefix and the logger’s console formatting. The tests still exercise the key behaviors (no info mirroring, warn on persistence/queue issues) without introducing new coupling.

test/constants.test.ts (1)

18-21: Constants test correctly tracks renamed plugin identity

The expectation for PLUGIN_NAME now matches the implementation ("openhax/codex"), keeping the branding and tests in sync.

test/prompts-codex.test.ts (1)

137-250: Codex prompt fetch tests remain accurate after prefix change

The failure and fallback expectations now use the [openhax/codex] tag but still assert the same behaviors: logging HTTP failures, falling back to cached or bundled instructions, and leaving shapes of messages and arguments unchanged. Looks good.

lib/logger.ts (1)

138-159: Uniform console logging guard looks correct

Removing the test-environment escape hatch so that !shouldLog always returns early makes debug/info suppression consistent across environments, while still allowing warn/error through. This matches the updated tests and shouldn’t affect production behavior.

test/prompts-opencode-codex.test.ts (1)

1-374: OpenCode Codex prompt tests comprehensively cover the new caching and fallback logic

This suite does a solid job of exercising the main and edge paths: session vs file cache, TTL handling, 304 conditional requests, network/non-200 failures, multi-URL (dev → main) fallback with sourceUrl persistence, cache directory creation, missing/malformed metadata, and cached-prefix reads. The mocked paths and expectations line up with the getOpenCodeCodexPrompt/getCachedPromptPrefix implementation, and I don’t see behavioral holes here.

lib/prompts/opencode-codex.ts (1)

15-25: No blockers on URL ordering and sourceUrl tracking; dev→main fallback looks correct.

Using OPENCODE_CODEX_URLS to prefer the dev branch and fall back to main, plus persisting sourceUrl in OpenCodeCacheMeta, cleanly separates which ETag belongs to which URL. The (!cachedMeta.sourceUrl || cachedMeta.sourceUrl === url) guard keeps conditional requests aligned with the stored origin while remaining backward‑compatible with legacy metadata that lacked sourceUrl. This all looks consistent with the rest of the function.

Comment thread lib/prompts/opencode-codex.ts
Comment thread lib/request/response-handler.ts
@riatzukiza riatzukiza force-pushed the chore/handle-missing-codex-prompt-warming branch from 71bfa3d to a98014d Compare November 19, 2025 23:56
@riatzukiza riatzukiza merged commit c0d7856 into staging Nov 19, 2025
11 checks passed
@riatzukiza riatzukiza deleted the chore/handle-missing-codex-prompt-warming branch November 19, 2025 23:57
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