Repository navigation
Conversation
…/redos)
MODERATION_REFUSAL_PROSE wrapped a verdict alternation and a tail
alternation in one ^(?:v)(?:t)*$ regex. Its category list consumed
separator words ("and retry") that a sibling tail option also accepts,
and its ",? and |, " separators overlapped, so a crafted upstream
error body (e.g. "refused category: a" + ", and retry category: a"
repeated) forced exponential backtracking before rejection
(CodeQL alerts lidge-jun#4342, lidge-jun#4343).
Split it into two anchored regexes consumed by an explicit scan: one
verdict, then tail phrases eaten greedily in order. The Azure wording
leads the verdict alternation because "the response was filtered" is a
strict prefix of it, and category separators are disjoint by first
byte, so every position has exactly one parse. Behavior verified
identical on a 29-case corpus; the attack string runs in ~0ms instead
of exploding exponentially.
Verified: bun test tests/routing/router-combo-failover-classification.test.ts
tests/routing/combo-failure-transport-parity.test.ts (228 pass),
bun run typecheck.
Co-Authored-By: Epinephrine <luvs01@hanmail.net>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Walkthrough
Merge Risk:
|
|
✅ READY
Hygiene✅ Deterministic PR hygiene checks passed. |
Direct coverage of isModerationRefusalProse (exported for tests): every accepted verdict and tail spelling, non-refusal bodies that must keep dev's decision, and both rejecting and accepting 80x-repeat category lists completing under a 1s bound (the previous nested-regex shape grew exponentially on the rejecting one). Registers the file in scripts/test-layout/layout.json and tests/fixtures/test-layout-expected.json under routing. Verified: bun test tests/routing/combo-failover-moderation-prose.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts (55 pass), bun run typecheck, bun run privacy:scan. Co-Authored-By: Epinephrine <luvs01@hanmail.net>
… scan Devin Review flagged two accepted-wording regressions on the rewritten matcher: the bare-verb verdict alternative won before the noun-phrased one that reaches `by ... system` (HTTP 400/422 + moderation code strings like "content refused by moderation system." were rejected), and the greedy category-list separator `, and ` swallowed retry-advice openings so "refused category: harassment, and retry later." failed to parse. Order the verdict scan Azure-first, then noun-phrased, then bare verb, then policy wording, and put a negative lookahead on the `, and ` separator for retry/try/please/to openings. The committed-test corpus now covers both regression shapes; equivalence vs the pre-fix regex holds at 0/42 divergences and the attack strings stay ~0.1ms vs >3.4s before. Co-Authored-By: Epinephrine <luvs01@hanmail.net>
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Previously supported moderation refusals stop combo failover — Confirmed both regressions: the bare-verb verdict alternative ran before the noun-phrased one reaching
by ... system, and the, andcategory separator swallowed retry-advice openings. Fixed in cedbd90 by ranking verdict alternatives longest-first (Azure → noun-phrased → bare → policy) and adding a lookahead (?!retry\b|try\b|please\b|to\b) on the, andseparator. Both reported strings added to the committed regression corpus; equivalence vs the pre-fix regex holds at 0/42 divergences and 216 focused tests pass.
Co-Authored-By: Epinephrine <luvs01@hanmail.net>
|
No description provided. |
|
@coderabbitai review |
Action performed
|
|
No description provided. |
|
The change is now tracked in lidge-jun/opencodex#8978, targeting upstream The two regression cases failed on the earlier fork head and passed after the correction. Local verification passed for 30 fork prose cases, 9 upstream classification cases, type checking, and the structure gate on both branches. Closing this fork PR as superseded by the open upstream PR. Review and CI continue upstream. |
…cktracking The added category-boundary cases also matched the old regex, so nothing failed if the scan were reverted. This case uses the CodeQL js/redos attack shape from #841: on origin/dev it takes about 976 ms per body (Bun's backtracking limit), on this head 1.4 ms.
…#8978) * fix(combos): preserve moderation category boundaries in a single scan Carry the bounded matcher from luvs01#841 and retain both category-list readings until the end of the message. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: keep category-list guidance within the structure budget * test(combos): pin the moderation category scan against exponential backtracking The added category-boundary cases also matched the old regex, so nothing failed if the scan were reverted. This case uses the CodeQL js/redos attack shape from luvs01#841: on origin/dev it takes about 976 ms per body (Bun's backtracking limit), on this head 1.4 ms. --------- Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: JUN <jun@lidgeai.com>
Summary
js/redosalerts fix(history): contain paginated metadata writes and preserve restore artifacts lidge-jun/opencodex#4342 and fix(update): retire observed exited pinned-start children lidge-jun/opencodex#4343 onMODERATION_REFUSAL_PROSE(src/combos/failover.ts), which ran upstream-supplied error prose through^(?:verdict)(?:tail)*$. Its category list swallowed separator words (", and retry") that sibling tail options also accept, and its,? and |,separators overlapped, so a crafted provider error body forced exponential backtracking before rejection — a small DoS surface on the failover path.isModerationRefusalProse: one verdict match, then tail phrases consumed greedily in order. The Azure wording now leads the verdict alternation because "the response was filtered" is a strict prefix of it, and the category separators are disjoint by first byte, so every position has exactly one parse.refused category: a+, and retry category: a× N +!), the old regex exploded exponentially (22ms at 15 reps → 698ms at 20 reps → minutes at the 2000-char cap); the new scan is flat ~0ms.Verification
Current integration — 2026-11-19
Current head:
31e5078742f928592d7f88287cdb98a688cbc975. Actual target-repository dev:0dc315b95a2493ed1fc6193a555f36d645ea186b, included by a normal merge (zero commits behind at publication). The published GitHub tree exactly matches the locally verified tree88a9825130a2e8cfa46d5b583d26ec98ef953542.This normal merge brings the branch forward from 73 commits behind actual dev. The bounded moderation matcher is preserved alongside dev's newer unoffered-tool-call classifier and branches. Both test-layout files retain current-dev mappings and this PR's regression entry.
bun test tests/routing/router-combo-failover-classification.test.ts tests/routing/combo-failure-transport-parity.test.ts tests/routing/combo-failover-moderation-prose.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts: 287 passed / 0 failed / 1,902 assertions.bun run typecheck: 2,589 files, no errors. Structure validation, privacy scan, file-size ratchet and whitespace checks against actual dev passed.bun test tests/ci-workflows/docs-spanish-localization.test.ts tests/ci-workflows/file-size-ratchet.test.ts: 57 passed / 0 failed / 3,388 assertions.Independent read-only integration review confirmed that the only runtime delta against dev is the moderation matcher: anchored verdict/tail scanning and the 2,000-character guard are preserved, and the unoffered-tool-call classifier and branches remain intact. No concrete blocker was found.
The repository's focused-validation exception applies to this integration and concurrent worktrees. The full local suite and broad
test:changedwere not run; hosted CI provides broader PR coverage. Native macOS/Windows and live-provider acceptance are not claimed.Hosted CI and review — 2026-11-19 03:38 UTC
Main CI, attempt 2 completed successfully for the exact current head above at 03:35:14 UTC. The retried shard 2/5 completed successfully from 03:20:57 to 03:35:08 UTC, including its test and post steps. The aggregate ci check is successful. Shards 1/5, 3/5, 4/5 and 5/5 retain their successful original executions. Catalog async contracts also completed successfully.
Attempt 1's shard 2/5 had been cancelled at the configured 15-minute job deadline/finalization boundary after all 61/61 batches reported
0 failand the test/post steps succeeded. The final batch reported 164 passed / 2 skipped / 0 failed / 860 assertions; the captured log contained no failed test result or nonzero failure summary. That incomplete attempt was not treated as a pass. Only the cancelled job received one bounded retry on this head; previously successful jobs and the entire workflow were not manually rerun. No CI label, timeout, assertion or workflow policy was changed.Current-head Devin Review completed successfully. CodeRabbit's current-head check is skipped because that app requires a manual review request; its earlier completed review remains historical coverage. All existing inline review threads remain resolved. No new external review comment or review-request message was posted.
The existing test-layout fixture delta selected the full Ubuntu shard lane under the unchanged repository policy. Successful hosted CI covers that selected lane; conditionally skipped native-platform jobs are not claimed as passed. The PR remains Ready for review. Maintainer security approval and applicable native-platform acceptance remain separate merge requirements.
Earlier evidence
The previous exact head
e8dc03a6371da59771e61b0af3b30f442cc81217had incomplete main CI, attempt 2: shards 2 and 3 again reached the 15-minute job limit in batches 60/63 and 63/64, without assertion failures in either captured log. Shards 1, 4 and 5 passed; that run's aggregate remained failed. One bounded failed-job retry had already been used. The earlier 29-case old-versus-new language corpus and timing comparison remain historical evidence.Checklist
Link to Devin session: https://app.devin.ai/sessions/3f957f3362db40dea0c40cb34195ac55
Open in Devin Desktop: https://app.devin.ai/desktop/session/3f957f3362db40dea0c40cb34195ac55?variant=devin
Requested by: @luvs01
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work
Summary by CodeRabbit