forked from lidge-jun/opencodex
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(responses): isolate policy compaction state #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
luvs01
wants to merge
4
commits into
dev
from
codex/propose-fix-for-compaction-routing-vulnerability
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
714119e
fix(responses): isolate policy compaction state
luvs01 aa9b889
fix(tests): bound the cold-spawn warm-up child on a live event loop
devin-ai-integration[bot] 7e59315
fix(responses): fail closed on synthetic or stale compaction source s…
devin-ai-integration[bot] a620f25
Merge remote-tracking branch 'origin/dev' into codex/propose-fix-for-…
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
tests/responses/responses-compaction-policy-identity.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { getDefaultConfig } from "../../src/config"; | ||
| import { routeConcreteModel } from "../../src/router"; | ||
| import { compactionRoutingKeepsProviderIdentity } from "../../src/server/responses/compaction-routing"; | ||
| import type { OcxConfig } from "../../src/types"; | ||
|
|
||
| function policyConfig(): OcxConfig { | ||
| return { | ||
| ...getDefaultConfig(), | ||
| defaultProvider: "openai-apikey", | ||
| providers: { | ||
| openai: { | ||
| adapter: "openai-responses", authMode: "forward", | ||
| baseUrl: "https://chatgpt.com/backend-api/codex", | ||
| }, | ||
| "openai-apikey": { | ||
| adapter: "openai-responses", authMode: "key", apiKey: "fixture-key", | ||
| baseUrl: "https://api.openai.com/v1", | ||
| }, | ||
| }, | ||
| routingProfiles: { | ||
| primary: { | ||
| alias: "ocx/primary", | ||
| candidates: [{ provider: "openai", model: "gpt-5.6-luna" }], | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| describe("compaction routing policy identity", () => { | ||
| test.each(["policy/primary", "ocx/primary"])("treats policy source %s as cross-identity", sourceModel => { | ||
| const config = policyConfig(); | ||
| const target = routeConcreteModel(config, "openai-apikey/gpt-5.6-luna"); | ||
|
|
||
| expect(compactionRoutingKeepsProviderIdentity(config, { sourceModel }, target)).toBe(false); | ||
| }); | ||
|
|
||
| test.each(["policy/primary--fast", "ocx/primary--fast"])( | ||
| "treats synthetic policy selector %s as cross-identity", | ||
| sourceModel => { | ||
| const config = policyConfig(); | ||
| const target = routeConcreteModel(config, "openai-apikey/gpt-5.6-luna"); | ||
|
|
||
| expect(compactionRoutingKeepsProviderIdentity(config, { sourceModel }, target)).toBe(false); | ||
| }, | ||
| ); | ||
|
|
||
| test("treats a stale policy alias as cross-identity after the profile is deleted", () => { | ||
| const config = policyConfig(); | ||
| delete config.routingProfiles; | ||
| const target = routeConcreteModel(config, "openai-apikey/gpt-5.6-luna"); | ||
|
|
||
| expect(compactionRoutingKeepsProviderIdentity(config, { sourceModel: "ocx/primary" }, target)).toBe(false); | ||
| }); | ||
|
|
||
| test("fails closed for a selector that only resolves through the default provider", () => { | ||
| const config = policyConfig(); | ||
| const target = routeConcreteModel(config, "openai-apikey/gpt-5.6-luna"); | ||
|
|
||
| expect(compactionRoutingKeepsProviderIdentity( | ||
| config, | ||
| { sourceModel: "unconfigured-model" }, | ||
| target, | ||
| )).toBe(false); | ||
| }); | ||
|
|
||
| test("retains identity for a concrete source on the target provider", () => { | ||
| const config = policyConfig(); | ||
| const target = routeConcreteModel(config, "openai-apikey/gpt-5.6-luna"); | ||
|
|
||
| expect(compactionRoutingKeepsProviderIdentity( | ||
| config, | ||
| { sourceModel: "openai-apikey/gpt-6-astra" }, | ||
| target, | ||
| )).toBe(true); | ||
| }); | ||
|
|
||
| test("retains identity for a concrete fast selector on the target provider", () => { | ||
| const config = policyConfig(); | ||
| const target = routeConcreteModel(config, "openai-apikey/gpt-5.6-luna"); | ||
|
|
||
| expect(compactionRoutingKeepsProviderIdentity( | ||
| config, | ||
| { sourceModel: "openai-apikey/gpt-6-astra--fast" }, | ||
| target, | ||
| )).toBe(true); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 Required full-suite validation remains incomplete
Review readiness requires
bun run testbefore approval. The PR reports that run was interrupted, so exact-head readiness remains unverified.Was this helpful? React with 👍 or 👎 to provide feedback.