Skip to content

fix(omp): preserve rich native model capabilities - #1365

Closed
dbc-hbin wants to merge 3 commits into
lidge-jun:devfrom
dbc-hbin:codex/local-omp-source-build
Closed

fix(omp): preserve rich native model capabilities#1365
dbc-hbin wants to merge 3 commits into
lidge-jun:devfrom
dbc-hbin:codex/local-omp-source-build

Conversation

@dbc-hbin

@dbc-hbin dbc-hbin commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Preserve unrelated OMP YAML comments and formatting by patching only providers.opencodex; unsupported or ambiguous YAML now fails closed.
  • Keep whole-file fingerprint protection for clients whose writers still re-serialize the complete document.
  • Extend OMP with model-level Responses routing for native OpenAI models while preserving image input and reasoning-effort controls.
  • Keep routed providers on Chat Completions and return a structured JSON 413 when translation exceeds its safe buffer.

Verification

  • bun run typecheck
  • bun run test
  • bun run privacy:scan
  • bun run build in docs-site/
  • Focused writer regression covers apply, stale refresh, and disable with a foreign provider, comments, quoted formatting, and post-apply source edits.
  • ocx restart was attempted for the new head and refused safely because the running proxy predates process-bound restart support; no stop/kill fallback was used.

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.

Review readiness checklist

  • All CI tests are green on my local testing.
  • I pushed my PR to the latest dev commit.
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features
    • Added OpenCodex model configuration support, including native Responses API selection, image inputs, context limits, and reasoning controls.
    • Exported configurations now include supported reasoning efforts, defaults, and input modalities.
  • Bug Fixes
    • Configuration updates preserve unrelated YAML comments, formatting, and line endings.
    • Unsafe or ambiguous configuration edits are rejected without modifying files.
    • Oversized Chat Completions replay bodies now return structured errors.
  • Documentation
    • Clarified configuration API behavior, formatting preservation, and ownership fingerprints.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b6334bab-561e-4c09-b72f-c0f4ba7023c6

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
📝 Walkthrough

Walkthrough

The PR adds OMP-specific model export with native OpenAI Responses support, preserves unrelated YAML source during OMP updates, scopes conflict detection to owned fragments, and adds guarded replay serialization with structured size errors.

Changes

OMP configuration export

Layer / File(s) Summary
OMP metadata contracts
src/clients/config-export.ts, src/codex/catalog.ts, src/server/management/model-rows.ts
Export models and native model rows now carry reasoning efforts, default reasoning effort, input modalities, and context windows.
OMP generation and registration
src/clients/config-export.ts, docs-site/src/content/docs/guides/integrations.md
OMP serialization filters unsupported models, selects openai-responses for native OpenAI models, retains openai-completions for routed models, and uses the OMP builder.
OMP export validation
tests/client-config-export.test.ts
Tests cover API selection, modalities, reasoning metadata, effort normalization, and omission of unsupported fields.

Owned-fragment integration state

Layer / File(s) Summary
Source-preserving OMP patching
src/integrations/omp-yaml-source.ts
OMP YAML mutations preserve unrelated bytes and fail closed when the managed provider block is ambiguous or unsupported.
Owned-fragment fingerprinting
src/integrations/ownership.ts, src/integrations/state.ts
OMP drift detection compares recorded managed fragments. Other clients retain whole-file comparison.
Integration writer wiring
src/integrations/writer.ts
Apply and disable use source-preserving OMP mutations and refuse unsafe changes.
Ownership and source-preservation validation
tests/integrations-state.test.ts, tests/integrations-writer.test.ts, tests/management-integration-routes.test.ts
Tests cover catalog drift, managed edits, unrelated fragments, formatting preservation, unsafe mutations, and conflict precedence.

Chat Completions replay serialization

Layer / File(s) Summary
Replay serialization and error handling
src/server/chat-completions.ts, tests/chat-completions-endpoint.test.ts
Guarded serialization returns structured HTTP 413 errors for oversized replay bodies and HTTP 500 errors for other serialization failures. Large image requests remain successful within the budget.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ModelCatalog
  participant NativeModelRows
  participant OmpConfigBuilder
  participant OmpGeneratedConfig
  ModelCatalog->>NativeModelRows: provide modalities and reasoning metadata
  NativeModelRows->>OmpConfigBuilder: provide exportable model rows
  OmpConfigBuilder->>OmpGeneratedConfig: select API dialect and serialize models
  OmpGeneratedConfig-->>OmpConfigBuilder: return generated OMP configuration
Loading

Possibly related PRs

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the OMP fix for preserving native model capabilities, which is a primary change in the pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

@dbc-hbin
dbc-hbin marked this pull request as ready for review August 9, 2026 16:22
@github-actions
github-actions Bot marked this pull request as draft August 9, 2026 16:22

@Wibias Wibias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Requesting changes for one blocking correctness/safety issue in the integration ownership change.

High — unrelated user-owned source text can now be silently destroyed

classifyIntegration() now intentionally ignores changes outside the recorded OpenCodex fragments, so a config can remain current when a user adds or edits an unrelated sibling such as another provider. That part is reasonable at the parsed-value level.

However, refresh/disable still parse the entire client config, remove/replace only the managed fragment in the parsed document, and then serialize the entire document back to disk. The YAML/TOML serializers are hand-renderers, and JSON/JSON5 are stringified, so comments and original formatting outside the managed fragment are not source-preserved.

Concrete example: after OpenCodex applies its provider block, the user adds an unrelated provider plus a YAML comment. With this PR the managed fragment still matches, so disable/refresh is allowed; the whole file is then re-rendered and the unrelated provider value survives, but the user's comment/formatting is silently lost.

That violates the writer's fail-closed safety contract: unrelated work performed after OpenCodex wrote the file must not be silently discarded merely because it sits outside the managed fragment.

Please either:

  • mutate only the owned subtree using a source-preserving mechanism, or
  • retain the whole-file conflict guard for formats where unrelated source text cannot be preserved.

Please also add an apply/refresh/disable regression that starts with an unrelated sibling plus comments/source formatting and proves those bytes survive the operation.

The OMP capability work itself looks sound: native OpenAI models use the model-level Responses API override, routed models remain on Chat Completions, image modalities are preserved, and the reasoning metadata matches OMP's accepted schema. The guarded Chat Completions replay-buffer 413 path also looks reasonable.

Merge gates after the blocker is fixed

  • rebase onto current dev (this head is behind)
  • run exact-head Cross-platform CI / React Doctor successfully
  • complete the readiness checklist / leave draft when ready

Please address the source-preservation hole before merge.

@dbc-hbin
dbc-hbin force-pushed the codex/local-omp-source-build branch from 85142f2 to 266e781 Compare August 10, 2026 00:30

dbc-hbin commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the blocking source-preservation finding in the latest-dev rebased head a328f438e.

  • Fragment-scoped ownership is now limited to OMP; whole-document serializers retain the whole-file fingerprint guard.
  • OMP apply/refresh/disable patch only the block-style providers.opencodex source range.
  • Ambiguous YAML or comments inside the managed range fail closed instead of falling back to whole-file serialization.
  • The regression starts with a foreign provider plus comments/quoted formatting, performs apply, a stale refresh after an unrelated post-apply edit, and disable, then asserts the unrelated bytes are restored exactly.
  • Exact-head full tests, focused 79 tests, typecheck, privacy scan, and docs build pass locally.

The PR remains draft while the new-head CI runs.

@dbc-hbin
dbc-hbin force-pushed the codex/local-omp-source-build branch from 266e781 to a328f43 Compare August 10, 2026 00:38
@Wibias
Wibias marked this pull request as ready for review August 10, 2026 00:43
@github-actions
github-actions Bot marked this pull request as draft August 10, 2026 00:49
@Wibias
Wibias marked this pull request as ready for review August 10, 2026 00:53
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 1 minutes and 30 seconds before sending another message.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 1 minutes and 19 seconds before sending another message.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@github-actions[bot] have exceeded the limit for the number of chat messages per hour. Please wait 1 minutes and 12 seconds before sending another message.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The PR is ready for review. I will review the current head.

⚠️ Action not completed

Already reviewed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]

This comment was marked as resolved.

@Wibias Wibias self-assigned this Aug 10, 2026
Repository owner deleted a comment from coderabbitai Bot Aug 10, 2026
Wibias added a commit that referenced this pull request Aug 10, 2026
…ne-comment

fix(omp): follow up source-preservation hardening for #1365

Wibias commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Thanks @dbc-hbin for the work here. This is genuinely useful: OMP now preserves the richer native OpenAI model capabilities through the Responses API, including image input and reasoning-effort metadata, while routed providers keep their existing Chat Completions path. The source-preserving YAML work also avoids clobbering unrelated user comments and formatting, which makes the integration much safer to use on real shared config files.

I'm closing this PR as superseded by #1392. #1392 contains the complete #1365 change set plus the follow-up source-preservation fix for nested inline comments inside providers.opencodex, together with refresh/disable regression coverage. That superset was rebased onto current dev, validated on the exact head, and has now been merged.

Thanks again for the contribution and for pushing the OMP integration forward. 🙏

@Wibias Wibias closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants