Skip to content

fix(routing): inspect hard-lock fallback without selecting candidates - #7683

Merged
lidge-jun merged 15 commits into
lidge-jun:devfrom
luvs01:fix/hard-lock-preflight-no-selection
Oct 25, 2026
Merged

lidge-jun merged 15 commits into
lidge-jun:devfrom
luvs01:fix/hard-lock-preflight-no-selection

Conversation

@luvs01

@luvs01 luvs01 commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Hard-lock fallback preflight currently selects a combo/profile candidate before normal dispatch, consuming selection state and potentially judging a mixed candidate set from one speculative choice. Inspect declared destinations without selecting them, and refuse early only when every resolved destination is policy-denied. Empty, mixed, same-destination, or unresolved declarations defer to normal selection and its actual-destination checks.

  • Preserve RNG/selection state, request bodies, independent provider/model policies, and send budgets during preflight.
  • Retain the landed profile/combo destination guards and emit no fallback-taken event for an early refusal.
  • Add regression coverage for aliases, mixed destinations, policy switches, events, and selection side effects.

The previous #7589 dependency has landed. This branch includes the shared Bun 1.4.4 test-runner transition from #7627 so validation uses the security baseline for both runtime and tests. The comparison with dev contains seven routing/documentation/test files and eleven shared transition files. It targets dev; directly using the older #7627 branch as base would expose unrelated intervening changes.

Verification

Candidate 083e4a89eadde42baf007083371bc6bcc7273d4e, official Bun 1.4.4 on Windows. A frozen install preserved the lockfile and verified actual consumer resolution of Hono 4.13.13, ip-address 10.7.4, and qs 6.16.1.

Ran each of these files once with CI=true bun test --isolate --timeout 60000:

  • tests/codex-integration/main-account-hard-lock-fallback-off.test.ts
  • tests/codex-integration/main-account-hard-lock-profile-dispatch.test.ts
  • tests/codex-integration/main-account-hard-lock-fallback-routing.test.ts
  • tests/routing/fallback-policy.test.ts
  • tests/codex-integration/main-account-hard-lock-policy.test.ts

202 passed, 0 failed, 0 skipped, 554 assertions; every process exited 0. Reference TypeScript, structure consistency, changed-file privacy/file-size checks, and git diff --check passed. Independent source review found no blocking defect. Test fixtures and owned processes were cleaned up; no live provider calls were made.

Full Bun 1.4.4 CI passed on this exact head: all four Linux test shards, all nine Windows shards, all three macOS shards and the macOS control succeeded. Path-filtered jobs were skipped as recorded in that run. The focused local tests above complement that hosted validation. No GUI change.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Summary by CodeRabbit

  • Bug Fixes

    • Improved fallback handling for hard-locked requests routed through combos or profiles. Requests are refused early only when all declared destinations are policy-denied; the selected destination is still checked before dispatch.
    • Preserved fallback-policy behavior for same-provider model changes and cross-provider routing.
  • Documentation

    • Updated contributor and runtime guidance to reflect Bun 1.4.4 for both runtime and test-runner roles, and clarified validation requirements.
  • Tests

    • Expanded coverage for fallback decisions, Bun runner selection, and early upload responses.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 083e4a8 and c1de534.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 488d5f1 and 083e4a8.

Files selected for processing: 18
  • .github/actions/setup-project-bun/action.yml
  • .github/workflows/ci.yml
  • CONTRIBUTING.md
  • Dockerfile
  • docs-site/src/content/docs/contributing.md
  • docs-site/src/content/docs/guides/fallback-off.md
  • package.json
  • src/server/responses/core-combo.ts
  • src/server/responses/main-hard-lock-routing.ts
  • src/server/responses/request-prepare.ts
  • structure/fallback-policy.md
  • structure/runtime.md
  • tests/ci-workflows/ci-scope-gaps.test.ts
  • tests/ci-workflows/install-scripts.test.ts
  • tests/claude-integration/claude-picker-upload.test.ts
  • tests/codex-integration/main-account-hard-lock-fallback-off.test.ts
  • tests/codex-integration/main-account-hard-lock-profile-dispatch.test.ts
  • tests/test-layout-tooling.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The pull request changes hard-lock preflight for combos and routing profiles, updates the Bun test-runner pin and related guidance, and adds an early-response TLS fixture to an upload integration test.

Changes: Hard-lock fallback routing

Layer / File(s) Summary
Declared-destination preflight
src/server/responses/main-hard-lock-routing.ts, structure/fallback-policy.md, src/server/responses/request-prepare.ts, docs-site/src/content/docs/guides/fallback-off.md, tests/codex-integration/main-account-hard-lock-fallback-off.test.ts
applyMainHardLockFallbackOverride checks declared combo and profile destinations without selecting a candidate. It refuses only when all destinations resolve and are denied. Tests cover policy precedence, unresolved targets, aliases, redirects, and preservation of selection state.
Selected-destination checks and dispatch validation
src/server/responses/core-combo.ts, structure/fallback-policy.md, tests/codex-integration/main-account-hard-lock-fallback-off.test.ts, tests/codex-integration/main-account-hard-lock-profile-dispatch.test.ts
The actual selected destination is still checked against the hard lock. Tests check refusals, dispatch-budget use, and fallback-event recording.

Bun test-runner version and validation

Layer / File(s) Summary
Test-runner pin and verification
package.json, tests/test-layout-tooling.test.ts, tests/ci-workflows/install-scripts.test.ts
The testRunnerBun pin and its test expectation change to 1.4.4. Runner tests cover caller-version matching, incorrect overrides, and test spawning.
Runtime-role and promotion guidance
.github/actions/setup-project-bun/action.yml, .github/workflows/ci.yml, CONTRIBUTING.md, Dockerfile, docs-site/src/content/docs/contributing.md, structure/runtime.md, tests/ci-workflows/ci-scope-gaps.test.ts
Documentation and comments describe 1.4.4 defaults for both roles, independent validation, and promotion after a successful full cross-platform lane=all run on the candidate head.

Early TLS response upload test

Layer / File(s) Summary
Early-response fixture and assertion
tests/claude-integration/claude-picker-upload.test.ts
The buffered early-response test uses a TLS server fixture and asserts that the response flushed before the request body completed.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant RequestPreparation
  participant applyMainHardLockFallbackOverride
  participant allDeclaredTargetsDenied
  participant NormalDispatch
  participant SelectedDestinationCheck
  RequestPreparation->>applyMainHardLockFallbackOverride: Check fallback declaration
  applyMainHardLockFallbackOverride->>allDeclaredTargetsDenied: Resolve declared destinations and evaluate policy
  allDeclaredTargetsDenied-->>applyMainHardLockFallbackOverride: Return all-denied or mixed/unresolved result
  applyMainHardLockFallbackOverride->>NormalDispatch: Continue without selecting or committing a hop
  NormalDispatch->>SelectedDestinationCheck: Check actual selected destination against hard lock
Loading

Possibly related issues

  • lidge-jun/opencodex issue 7587: It describes the exhausted-main-account workflow involving profile or combo destinations. This pull request changes the corresponding hard-lock preflight behavior; the broader desktop compatibility work is not included.

Possibly related PRs

  • lidge-jun/opencodex#7627: It supplies the Bun 1.4.4 test-runner transition and related validation changes.
  • lidge-jun/opencodex#7606: It changes the shipped Bun runtime pin to 1.4.4, which this pull request matches for the test-runner role.
  • lidge-jun/opencodex#7589: It added the actual first ranked routing-profile destination guard that this pull request retains alongside the new preflight.
Merge Risk: Minimal · up to 083e4

The changes appear mergeable after normal checks; no actionable issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 9 files. (9 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the primary change: hard-lock fallback preflight now inspects declared destinations without selecting combo or profile candidates. It is concise, specific, and directly…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title accurately summarizes the primary change: hard-lock fallback preflight now inspects declared destinations without selecting combo or profile candidates. It is concise, specific, and directly related to the routing changes.

Full details: Docstring Coverage

Explanation

Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 9 files. (9 skipped: 9 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 24, 2026
@luvs01
luvs01 marked this pull request as ready for review October 24, 2026 15:54
…k-preflight-no-selection

# Conflicts:
#	tests/claude-integration/claude-picker-upload.test.ts
@lidge-jun

Copy link
Copy Markdown
Owner

Integration evidence (owner decision decision:b607a677, approved): after #7627 landed the maintainer merged origin/dev into this branch, leaving only this PR's own change (hard-lock fallback inspection (main-hard-lock-routing.ts, core-combo.ts, request-prepare.ts)); independent gpt-6.1-sol review PASS at exact head c1de534. Exact-head PR CI run 40156543505 and exact-head ci.yml lane=all run 40156893227 (maintainer mirror branch at this SHA) both succeeded.

Static merge simulation on current dev 6728882 (this Mac): dev=6728882a30c998ba025ac24769a00239a13a393f base=323a5e11772c38c15b271d23c7696c5947bb97da pr_files= 7 overlap=[]; merge clean; install exit=0; gui install exit=0; tsc exit=0; tsc doctor exit=0; structure:check exit=0; privacy:scan exit=0; layout+ratchet guards exit=0 54 pass 0 fail ;

Merged by the triage manager as maintainer integration (MAINTAINERS.md, dev only) with green exact-head PR CI, an independent review PASS, and the owner's approval of this bundle.

@lidge-jun
lidge-jun merged commit c203c86 into lidge-jun:dev Oct 25, 2026
62 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants