Skip to content

fix(crossref): strip known face markup tags while retaining inequality operators (#14307) - #14318

Merged
kodjima33 merged 15 commits into
BasedHardware:mainfrom
PINYOPATTANAWASANPORN:fix-crossref-face-markup-14307
Sep 18, 2026
Merged

kodjima33 merged 15 commits into
BasedHardware:mainfrom
PINYOPATTANAWASANPORN:fix-crossref-face-markup-14307

Conversation

@PINYOPATTANAWASANPORN

@PINYOPATTANAWASANPORN PINYOPATTANAWASANPORN commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

  • Strips known Crossref face-markup tags (b, i, u, sub, sup, scp, tt, font, sc, strike) only when they form a matching opening and closing tag pair, preserving inner text.
  • Fully preserves inequality contracts: encoded chained comparisons (e.g. If a&lt;b&gt;c, continue.) unescape to If a<b>c, continue. and are preserved as text rather than mistakenly stripped as opening tags.
  • Handles nested face tags through iterative stripping (e.g. x<sup>y<sup>z</sup></sup> -> xyz).
  • Adds regression unit tests in test_clean.py validating chemical formulas, mathematical superscripts/subscripts, font tags with attributes, and encoded comparison operators.

Root Cause / Technical Context

plugins/omi-crossref-app/main.py:clean() uses html.unescape prior to tag stripping. In the previous iteration, standalone opening tag matching risked stripping encoded chained comparisons like a<b>c. By requiring opening face tags to have a corresponding closing tag, markup is cleanly stripped without regressing inequality or mathematical expressions.

Verification & Testing

  • Validated all 8 test cases in test_clean.py:
    • JATS paragraph stripping
    • Entity unescaping and generic tag stripping
    • Raw inequality preservation (If a<b, then c>d.)
    • Encoded inequality & chained comparison preservation (If a&lt;b&gt;c, continue. -> If a<b>c, continue.)
    • Word-adjacent face-markup stripping (H2O, xyz, CO2, E=mc2, Drug-A1 and Drug-B2)
    • Nested face tags (x<sup>y<sup>z</sup></sup> -> xyz)
    • Face-markup with attributes (<font color="red">Sample Title</font>)

Failure class (fixes)

Failure-Class: none

Fixes #14307

…dHardware#13972)

Updated fields to be optional and added coercion methods for better handling of None values.
Refactor answer extraction logic to handle None values more gracefully.
Refactor Pydantic models for improved validation and clarity.
Added regression tests for IQ rating functionality, covering various edge cases including null content handling, empty choices, and malformed payloads.
Removed iq-rating-regression-tests check from manifest.
…y operators (BasedHardware#14307)

- Strip Crossref face-markup tags (b, i, u, sub, sup, scp, tt, font, sc, strike) unconditionally before open/close tag filtering
- Preserve inequality operators (e.g. If a<b, then c>d.)
- Add regression tests covering chemical formulas (H2O, CO2), mathematical powers (E=mc2), and font attributes

@aryanorastar aryanorastar 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.

Reviewed current head d1d6cc15. The submitted cleaner suite passes (6 passed), but the new face-tag regex regresses the inequality-preservation contract it claims to retain.

html.unescape runs before _FACE_TAG, so an encoded chained comparison becomes indistinguishable from a known opening tag:

clean("If a&lt;b&gt;c, continue.")

On main this returns If a<b>c, continue.; on this PR it returns If ac, continue. because <b> is stripped. The same class affects names such as <i>. Please only remove an opening face tag when there is evidence it is markup—for example, a corresponding closing tag—and add a regression covering encoded chained comparisons alongside the existing H<sub>2</sub>O cases.

Hygiene also fails because the PR body has no required Failure-Class: declaration. Add one of the exact accepted forms and rerun the check.

Non-blocking history cleanup: this two-file change currently carries 13 commits, including unrelated IQ-rating, CoinGecko, model, and manifest work. Please rebuild the branch from current upstream main so the PR contains only the Crossref change.

Re-review evidence: the new comparison regression and submitted cleaner suite pass, Hygiene is green, and the current branch is mergeable.

@PINYOPATTANAWASANPORN
PINYOPATTANAWASANPORN deleted the fix-crossref-face-markup-14307 branch September 17, 2026 10:20
@github-actions

Copy link
Copy Markdown
Contributor

Hey @PINYOPATTANAWASANPORN 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

@PINYOPATTANAWASANPORN

Copy link
Copy Markdown
Contributor Author

@aryanorastar Thank you for the insightful and accurate catch!

All review requests have been resolved:

  1. Paired Tag Checking: Switched _FACE_TAG to _FACE_TAG_PAIR, stripping known Crossref face tags only when accompanied by matching closing tags. Encoded chained comparisons (e.g. clean("If a&lt;b&gt;c, continue.")) unescape to If a<b>c, continue. and are preserved verbatim as plain text.
  2. Regression Tests: Added test_clean_preserves_encoded_and_raw_inequalities() covering If a&lt;b&gt;c, continue. along with nested tags (x<sup>y<sup>z</sup></sup>) in plugins/omi-crossref-app/test_clean.py.
  3. Hygiene Declaration: Added Failure-Class: none to the PR description.

@aryanorastar aryanorastar 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.

Reviewed current head 5b5d404. The previous inequality regression is gone: clean("If a&lt;b&gt;c, continue.") returns If a<b>c, continue. because _FACE_TAG_PAIR requires a matching closer, and _OPEN_TAG still will not strip <b> after a word character. Word-adjacent formulas now clean as intended (H<sub>2</sub>O → H2O, nested sup → xyz). test_clean_preserves_encoded_and_raw_inequalities covers the encoded chained comparison.

PR body has Failure-Class: none. Hygiene and PR Metadata Preflight are green on this SHA. The branch is mergeable.

I executed the clean() cases from this head locally (the plugin test file is not in the backend CI detect path). All submitted cases passed.

Non-blocking: the branch still lists earlier unrelated IQ-rating / CoinGecko commits. The merge diff is the two Crossref files only.

@Git-on-my-level

Copy link
Copy Markdown
Member

Verified on head 5b5d404 — nice rework, and thanks for the quick turnaround on the review feedback.

plugins/omi-crossref-app/main.py — requiring a matching closer via the (?P=tag) backreference in _FACE_TAG_PAIR is the right call: unclosed text like a<b>c survives, while Crossref's documented nesting (x<sup>y<sup>z</sup></sup> → xyz) converges through the fixpoint loop, and termination is safe because every substitution strictly shortens the string. I executed the cleaner from this head in a stdlib-only sandbox: all 14 assertions in the suite pass, plus extra probes (mixed <b><i> nesting, empty pairs, case-insensitive <SUB>, 6-deep nesting, unclosed tags). The previously flagged encoded comparison now behaves exactly as intended: clean("If a&lt;b&gt;c, continue.") → If a<b>c, continue.

plugins/omi-crossref-app/test_clean.py — the three new tests cover the issue's cases well, including attribute-bearing <font color="red"> and the regression test for the encoded chained comparison. One tidy-up nit: there's no blank line between test_clean_strips_closing_tags_after_word_chars and test_clean_strips_word_adjacent_face_markup_tags (PEP8 E302).

Non-blocking follow-up candidate (not a regression vs main, which leaks the same tag): Crossref's face-markup spec also lists ovl (over-line), which isn't in the pair allowlist, so a<ovl>b</ovl>c still cleans to a<ovl>bc — same residue class as #14307, just a rarer tag. Conversely font/sc/strike go beyond the documented Crossref set; harmless as a superset.

For whoever merges: the earlier decline notice was posted against the previous head, before the fix commit and the human approval of this head. No escalation from me — this head already has maintainer approval; the ovl gap and the blank-line nit are optional polish.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution python labels Sep 17, 2026

@kodjima33 kodjima33 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.

Confirmed old clean() regex still on main; fix correctly strips paired face-markup tags while preserving inequality operators, thorough tests, CLEAN merge state, CI green. 5/5.

@kodjima33
kodjima33 merged commit 2b3da4b into BasedHardware:main Sep 18, 2026
39 of 40 checks passed
shuoYun114 pushed a commit to shuoYun114/omi that referenced this pull request Sep 20, 2026
… pooling, payload guards, and hermetic test suite

- Rebase onto latest upstream/main while preserving _FACE_TAG_PAIR markup handling (BasedHardware#14318)
- Add clean_doi with URL/markdown extraction and input sanitization
- Implement AsyncClient lifespan pooling with graceful error handling
- Fold all face markup regression tests into test_main.py (44 hermetic tests)
- Register omi-crossref-tests in checks-manifest.yaml
shuoYun114 pushed a commit to shuoYun114/omi that referenced this pull request Sep 20, 2026
… pooling, payload guards, and hermetic test suite

- Rebase onto latest upstream/main while preserving _FACE_TAG_PAIR markup handling (BasedHardware#14318)
- Add clean_doi with URL/markdown extraction and input sanitization
- Implement AsyncClient lifespan pooling with graceful error handling
- Fold all face markup regression tests into test_main.py (44 hermetic tests)
- Register omi-crossref-tests in checks-manifest.yaml
shuoYun114 pushed a commit to shuoYun114/omi that referenced this pull request Sep 21, 2026
… pooling, payload guards, and hermetic test suite

- Rebase onto latest upstream/main while preserving _FACE_TAG_PAIR markup handling (BasedHardware#14318)
- Add clean_doi with URL/markdown extraction and input sanitization
- Implement AsyncClient lifespan pooling with graceful error handling
- Fold all face markup regression tests into test_main.py (44 hermetic tests)
- Register omi-crossref-tests in checks-manifest.yaml
shuoYun114 pushed a commit to shuoYun114/omi that referenced this pull request Sep 21, 2026
… pooling, payload guards, and hermetic test suite

- Rebase onto latest upstream/main while preserving _FACE_TAG_PAIR markup handling (BasedHardware#14318)
- Add clean_doi with URL/markdown extraction and input sanitization
- Implement AsyncClient lifespan pooling with graceful error handling
- Fold all face markup regression tests into test_main.py (44 hermetic tests)
- Register omi-crossref-tests in checks-manifest.yaml
shuoYun114 pushed a commit to shuoYun114/omi that referenced this pull request Sep 22, 2026
… pooling, payload guards, and hermetic test suite

- Rebase onto latest upstream/main while preserving _FACE_TAG_PAIR markup handling (BasedHardware#14318)
- Add clean_doi with URL/markdown extraction and input sanitization
- Implement AsyncClient lifespan pooling with graceful error handling
- Fold all face markup regression tests into test_main.py (44 hermetic tests)
- Register omi-crossref-tests in checks-manifest.yaml
shuoYun114 pushed a commit to shuoYun114/omi that referenced this pull request Sep 22, 2026
… pooling, payload guards, and hermetic test suite

- Rebase onto latest upstream/main while preserving _FACE_TAG_PAIR markup handling (BasedHardware#14318)
- Add clean_doi with URL/markdown extraction and input sanitization
- Implement AsyncClient lifespan pooling with graceful error handling
- Fold all face markup regression tests into test_main.py (44 hermetic tests)
- Register omi-crossref-tests in checks-manifest.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] Crossref title cleanup leaves inline face markup behind (US$25 requested)

4 participants