Skip to content

fix(responses): isolate policy compaction state - #565

Closed
luvs01 wants to merge 4 commits into
devfrom
codex/propose-fix-for-compaction-routing-vulnerability
Closed

luvs01 wants to merge 4 commits into
devfrom
codex/propose-fix-for-compaction-routing-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent policy-routed selectors (e.g. policy/<id> or configured aliases) from being mistaken as the same provider identity during compaction routing, which could leak provider-private encrypted reasoning or native compaction blobs across backends.

Description

  • Treat routing-policy selectors as cross-identity in compactionRoutingKeepsProviderIdentity by checking resolvePolicyProfileId and returning false when the source is a policy selector, instead of reconstructing identity via routeConcreteModel.
  • Preserve the existing concrete-case behavior so a concrete provider/model on the same provider still returns true and keeps native compaction where appropriate.
  • Add a focused regression test tests/responses/responses-compaction-policy-identity.test.ts covering canonical policy/<id>, configured alias, and a same-provider concrete control case.
  • Update the Responses transport contract doc (structure/transports/responses.md) and register the new test in scripts/test-layout/layout.json and tests/fixtures/test-layout-expected.json.

Testing

  • Ran bun test tests/responses/responses-compaction-policy-identity.test.ts which passed (3 pass, 0 fail).
  • Ran bun run typecheck which completed successfully.
  • Ran bun run structure:check which passed.
  • Ran bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts which passed (18 pass, 0 fail).
  • Ran bun run privacy:scan which passed.
  • bun run test:changed could not run in this checkout due to no resolvable comparison ref; full-suite bun run test encountered unrelated environment/live-server failures and was interrupted, but these failures are external to the focused change and the new regression is green.

Codex Task


Devin Review

@coderabbitai

coderabbitai Bot commented Sep 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 47084131-6b33-40ad-a066-e5edda69569a


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

Deterministic PR hygiene checks passed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-20T12:52:42.404610Z 714119e PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

Copy link
Copy Markdown

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 test before approval. The PR reports that run was interrupted, so exact-head readiness remains unverified.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/server/responses/compaction-routing.ts Outdated
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration Bot and others added 2 commits September 20, 2026 13:40
The warm-up child was waited on through Bun.spawnSync, which made the spawn's
own timeout the only bound it could honour — and no bound at all when the
child or the primitive wedged: while a synchronous spawn blocks, the event
loop is dead, so the hook budget and the per-test timeout freeze inside the
same wait and nothing reports anything. Run 35511743422's macos 2/2 leg held
that shape for eighteen silent minutes inside client-connect.test.ts before
the job ceiling cut it and reported cancelled, which the ci gate reads as
failure.

The bound now lives on the parent's live loop: an asynchronous spawn, SIGKILL
at the existing derived deadline, a short reap grace, and the call settles
with or without the child's exit or EOF — so a descendant holding the pipes
or a child that outlives its kill cannot turn a warm-up into an unbounded
wait. A timed-out child now fails the warm-up by name instead of hanging the
job.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…electors

compactionRoutingKeepsProviderIdentity evaluated override.sourceModel as the
raw client selector, so a synthetic --fast/--effort form of a policy or combo
selector (ocx/primary--fast) missed resolvePolicyProfileId/resolveComboId and
fell through routeConcreteModel to the default provider. The same fallthrough
swallowed policy aliases renamed or deleted mid-conversation, since
config.routingProfiles is mutated in place. Both cases could wrongly report
identity match and let provider-private compaction state or caller credentials
cross a backend boundary.

Strip synthetic-row suffixes via parseSyntheticRowId before the identity
checks, and treat a source that only routes through the default provider as
unproven: it can never match a concrete identity.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
@devin-ai-integration

Copy link
Copy Markdown

Fixed in 7e59315. compactionRoutingKeepsProviderIdentity (and the combo-lane recall in applyCompactionRoutingOverride) now normalize sourceModel through parseSyntheticRowId before the identity checks, so synthetic --fast/--effort forms of policy and combo selectors (e.g. ocx/primary--fast) resolve to their base id and hit the resolvePolicyProfileId/resolveComboId guards instead of falling through routeConcreteModel to defaultProvider. Regression cases added in tests/responses/responses-compaction-policy-identity.test.ts.

@devin-ai-integration

Copy link
Copy Markdown

Fixed in 7e59315 with a fail-closed posture rather than preserving stale aliases: a source selector that reaches routeConcreteModel only via routeReason === "default-provider" can no longer match a concrete identity (renamed/deleted policy aliases land exactly there, since config.routingProfiles is mutated in place). Such selectors now report cross-identity, so compaction falls back to the portable path instead of forwarding provider-private state across the backend boundary. Trade-off: genuinely unconfigured models on the default provider degrade to portable compaction rather than native. Regression cases cover the stale-alias and unconfigured-selector paths in tests/responses/responses-compaction-policy-identity.test.ts.

@luvs01

luvs01 commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Consolidated into lidge-jun#5553 as a single related-function aggregate.

Source head: a620f2506b2278d515b988ccb1e1d65db3cbcf2f. Replacement head: 67c4f579e4fb5201dcd36be225ee54306d78e63e.

All three unique commits 714119e, aa9b889 and 7e59315 are preserved in e6f9339, f86a534 and 76b40f9 with exact stable patch IDs and original authors. This includes the cold-spawn process-lifecycle follow-up and the synthetic/stale selector identity correction. The dev synchronization merge has no additional resolution delta. The final aggregate preserves all prepared contribution files and passed 604 distinct focused tests, including compaction identity and warm-up lifecycle. Full-suite completion, exact-head hosted CI and security review are explicitly pending on the draft replacement.

Closing this duplicate standalone review entry as part of the requested consolidation after verifying coverage. This is not a merge or release claim; remaining integration checks and reviews are tracked on the replacement. Original branches are retained.

@luvs01 luvs01 closed this Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant