Skip to content

fix(plugins): normalize Crossref abstracts before truncation - #13256

Closed
kaijakagi-sys wants to merge 6 commits into
BasedHardware:mainfrom
kaijakagi-sys:fix/crossref-plain-abstract-13242
Closed

kaijakagi-sys wants to merge 6 commits into
BasedHardware:mainfrom
kaijakagi-sys:fix/crossref-plain-abstract-13242

Conversation

@kaijakagi-sys

@kaijakagi-sys kaijakagi-sys commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up for #13242, retaining the upstream #13525 fix and version 1.0.1. The merged regex cleaner fixes basic JATS tags, but the original handler regressions still expose lost paragraph/break boundaries, escaped literal text, CDATA payloads, inline markup and incorrect visible-text truncation. This same-PR merge preserves upstream clean() and test_clean.py unchanged; only abstracts use the original markup-aware parser. Other metadata retains current upstream behavior. No mathematical layout rendering is claimed.

Validation

  • Against current upstream 9180aff, our unchanged seven production-handler tests report ten failed assertions; repaired sources pass those seven plus an eighth handler control preserving the raw inequality from upstream fix(crossref): strip JATS markup from abstracts #13525. That control failed the earlier parser before the bounded handling of invalid XML tag names and valueless attributes (raw comparisons with and without a comma).
  • Upstream test_clean.py remains byte-identical and its four test functions pass using the same hermetic module loader.
  • The public Crossref fixture captured September 9 and existing JATS/CDATA/escaped text cases are unchanged. Framework/model doubles and a controlled provider seam exercise the complete production DOI handler, not HTTP routing, Pydantic serialization, live Crossref or deployed UI.
  • The provider-specific regression is registered in both local and CI manifest lanes; it catches the failure behind Crossref work lookup returns raw JATS markup in the abstract #13242, with residual cases still failing after fix(crossref): strip JATS markup from abstracts #13525. A shared primitive is not needed for one integration's abstract contract.
  • make preflight and scripts/pr-preflight --lane local --pr-body-file <draft>: all 14 selected local checks pass. The history-dependent failure-class guard ratchet explicitly skips in this shallow checkout; full-history hosted CI remains authoritative. git diff --check passes. Hosted CI must confirm the published head.

Product invariants affected

none

Failure-Class: none

Reward status

The suggested $50 in #13242 remains unapproved, not funded. Small PR-first contribution under the published discretionary program; merge, sponsor award, official claim and receipt are separate. No assignment, bounty approval or payment claimed.

Exercise production DOI handler: five tests pass; unchanged source fails eight cases. Local preflight: 14 checks pass (shallow-history ratchet skips).

Failure-Class: none

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread plugins/omi-crossref-app/main.py Resolved
Comment thread plugins/omi-crossref-app/main.py Resolved
Reproduce both review findings on prior published head; five new subcases fail before and all seven handler tests pass after. Fourteen selected local checks pass; shallow-history ratchet skips. No live HTTP/deployment test.

Failure-Class: none

Copy link
Copy Markdown
Contributor Author

Addressed both review findings in 8054d46: JATS break elements preserve word boundaries, and CDATA payloads remain literal text before truncation. Five new regression subcases fail against the previous PR head; all seven handler tests and all 14 selected local preflight checks pass with the correction. The shallow-history ratchet still skips; HTTP routing and deployed behavior remain unverified.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified against #13242 — this is a tight, correct fix. What I checked, per file:

  • plugins/omi-crossref-app/main.py — AbstractTextParser collects character data and inserts newlines only for block-level tags (p, title, sec, div, br, break, li, matched after namespace stripping via tag.rsplit(":", 1)[-1]); clean_abstract() parses before entity decoding so &lt;sample&gt; stays literal text, and unknown_decl() keeps CDATA payloads literal. The only call-site change is abstract = clean_abstract(item.get("abstract")) in get_crossref_work, so the search and author handlers and all other metadata normalization are untouched. The existing abstract[:1200] cap now counts visible text instead of JATS markup.
  • plugins/omi-crossref-app/test_main.py — I ran the suite against both this head and base main in a clean stdlib-only container: 7/7 pass on the head, while the same cases produce 13 failing subcases on base, so the regression coverage is real (captured public Crossref response for 10.7554/eLife.45374, MathML inline data, escaped literals, unclosed markup, cap ordering, CDATA, provider errors, empty abstracts). Loading the production module with framework/model doubles keeps it hermetic — nice approach.
  • I also probed beyond the suite: namespaced block tags with attributes, nested jats:sec/jats:title, uppercase tags, numeric character references, and adversarial floods (50k escaped entities, 100k <break/> elements) — all behave sensibly with linear runtime, so no parser-blowup concern.
  • .github/checks-manifest.yaml — the new crossref-abstract-tests entry follows the manifest's own conventions: reason string cites #13242, both local and ci lanes declared, stdlib-only command, trigger scoped to plugins/omi-crossref-app/**. Nothing in the workflow files or secrets is touched.
  • plugins/omi-crossref-app/README.md — the new section matches the code's actual behavior (plain-text conversion before the 1,200-char limit, paragraph separation, literal escaped brackets, no math layout), and the documented python3 plugins/omi-crossref-app/test_main.py invocation works from the repo root.

Minor, non-blocking: subscript/superscript content concatenates with adjacent text (x<sub>i</sub><sup>2</sup> → xi2) — fine for a plain-text tool response and intentionally pinned by a test; empty block elements filter out cleanly.

Before merge: no CI checks have reported on this head yet — the new manifest entry should exercise this suite in the ci lane, so let that run confirm. On the reward question from #13242: that's a maintainer decision I can't confirm here. Leaving the merge call to a human maintainer.


This feedback is AI-generated on behalf of the maintainers. A human maintainer should make the final merge decision.


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 9, 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.

backend/community fix: confirmed on main clean() leaves raw JATS/XML tags in Crossref abstracts before the 1200-char truncation; new HTMLParser-based clean_abstract correctly strips markup. Linked issue #13242 real, diff scoped, tests added.

Preserve both regression registrations and all upstream changes; plugin code unchanged.
Crossref: 7 tests pass. Upstream USGS: 5 tests pass.
Exact-base local preflight: 14 checks pass; shallow-history limit remains.
No live provider, OAuth or deployment verification.
@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up on the merge head 9ae0af9: the only new commit since my earlier review is a merge of current main, and it does not touch this PR's content — plugins/omi-crossref-app/main.py, test_main.py, and README.md are byte-identical to the reviewed 8054d46, and the extra .github/checks-manifest.yaml lines are upstream test registrations with the crossref-abstract-tests entry intact.

I re-ran the handler suite against the exact head sources in a clean standard-library-only sandbox: 7/7 pass, including the JATS break word-boundary and CDATA-literal truncation regressions added after the first review round. All checks are green on the merge head.

With @kodjima33's approval already on record and no plugin-content change since it was given, this looks merge-ready from my side — nothing further needed from you. Thanks for keeping the branch current.


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

Retain upstream regex cleaning, tests and version 1.0.1. Preserve original abstract-only character-data parsing and regression coverage for residual CDATA, escaped literals, boundaries and visible-text truncation. Preserve upstream raw inequality controls through the actual DOI handler.

Failure-Class: none

Copy link
Copy Markdown
Contributor Author

The completed Desktop Swift CI job for 1e07f26cfa74ea27ba2da68fda2f2a601f5ef6b6 failed its overall timing budget:

  • Build succeeded in 456.50s. The first worker-0 batch exited 143 after 1,651s against a 1,500s invocation budget; its two automatic half-batch retries then passed in 45s and 58s.
  • The harness reported 824 suites run, but the complete Swift suite step took 2,381s against its 1,800s regression budget. This is still failed CI; the log does not identify a failing Crossref assertion or establish a specific root cause.
  • This head and base 9180aff1c907841c558bd8fa095bf44c36a89652 have identical desktop/ trees and identical .github/workflows/desktop-swift-ci.yml. The four changed files are the Crossref plugin source, tests, README, and check registration.

For comparison, Calendar #13284 has now hit a similar overall-budget failure in run 34718293316: 2,215s against 1,800s. Its timed-out 74-suite batch passed as two 37-suite halves (33s each); an earlier nonzero 100-suite batch also passed when split. Its desktop tree and Swift workflow likewise match base 9180aff1. Both runs report 824 suites run and defer the existing 32 slow suites to the full lane; neither is full desktop clearance.

Could a maintainer advise how this timing failure should be handled for this plugin-only change? I have not changed desktop code or raised its budget.

@Git-on-my-level

Copy link
Copy Markdown
Member

Re-verified head 1e07f26 after the main merge — the plugin work is still sound, and all three red checks trace to causes outside this diff.

What changed since the approved 8054d46, per file:

  • plugins/omi-crossref-app/main.py — the delta is exactly: upstream fix(crossref): strip JATS markup from abstracts #13525's regex clean() retained byte-for-byte (titles, DOIs, years, publishers keep current main behavior), a guard in AbstractTextParser.handle_starttag (re.fullmatch(r"[A-Za-z_][A-Za-z0-9_.:-]*", tag) plus the valueless-attribute check) so comparison tokens like a<b, stay literal text, and the 1.0.1 version bump. Abstracts remain the only clean_abstract() call site in get_crossref_work, so the 1200-char cap counts visible text, not JATS markup.
  • plugins/omi-crossref-app/test_main.py — I ran the suite against the exact head sources in a standard-library-only sandbox: 8/8 pass, including the new raw-inequality control cases ("If a<b, then c>d." and "If ad.").
  • plugins/omi-crossref-app/README.md and test_clean.py — README claims match the code (paragraph separation, escaped-literal and CDATA handling, no math-layout claim); upstream test_clean.py is byte-identical to base 9180aff (blob 14c410b).
  • .github/checks-manifest.yaml — net diff vs base is only the crossref-abstract-tests entry, same shape as the sibling plugin registrations.

On the three red checks at 1e07f26, for the maintainer question above:

  • Dart Analyze & Tests fails on compile-time analyzer errors in app/test/providers/deletion_consistency_test.dart and app/test/widgets/chat_content_blocks_test.dart (ActionItemsFetcher type mismatch). This PR touches no Dart files and those test files are unchanged on main since Aug 21 — main-side breakage, not this change.
  • Both Desktop Swift lanes trace to a single wall-clock overrun: 824 suites ran with zero failing suites, the suite step took 2381s against its 1800s regression budget, and the one nonzero batch passed cleanly when split (45–58s halves). desktop/ and .github/workflows/desktop-swift-ci.yml are byte-identical to base 9180aff, so a plugins-only change cannot have affected Swift code paths; Calendar fix(plugins): preserve Google Calendar timestamp offsets #13284 shows the same overrun pattern on an equally untouched desktop tree.

So the plugin change itself is verified correct and previously approved; the failures are CI timing plus main-side Dart breakage. Whether to re-run, merge on red-but-unrelated required checks, or adjust the Swift budget is a maintainer CI-policy call — @kodjima33 the verification above should give you what you need to decide. Thanks for the patient, well-documented iterations on this.


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

… for BasedHardware#13256

Preserve the reviewed plugin files unchanged. Component regression tests, make preflight and explicit PR-body preflight pass locally; hosted mobile and Swift CI remain authoritative.

Copy link
Copy Markdown
Contributor Author

On current head 3415daf1457964f9f70817a3bf0252cbf968a79b, Mobile App Checks now passes, including Dart Analyze & Tests and Android Compile Smoke.

Repo Checks run 34749356321 failed at Detect Changes job 103702899858. The job API reports failure but returns no step details; Formatting and Hygiene were skipped. Log retrieval returned 404, so I cannot establish the cause or identify an author-side correction. Desktop Swift CI is still pending.

Could a maintainer inspect this Detect Changes failure and, if appropriate, rerun only that failed job? I have not changed the workflow or retriggered the run.

Copy link
Copy Markdown
Contributor Author

The earlier Detect Changes blocker is cleared on current head e13a59656454197d3f710c5e791f2ae78ce82768: Repo Checks run 34763879386 now passes. Detect Changes and Hygiene, including the shared PR contract preflight, both succeeded; Formatting was skipped.

Eight of the nine workflows have succeeded. Desktop Swift CI is still queued, so this is not full CI clearance yet. No rerun of the older failed detector job is needed for this head.

Copy link
Copy Markdown
Contributor Author

The remaining Desktop Swift CI run has now succeeded on e13a59656454197d3f710c5e791f2ae78ce82768. The actual desktop Swift app tests, launcher script tests, release compile and independent phase verdicts passed. All nine returned workflows report success. The macOS-scoped manifest checks and release-mode UserNotifications regression were skipped; this is not a claim that every check executed.

This closes the pending-Swift caveat in my previous update. GitHub reports the unchanged head mergeable. Could a maintainer review the retained abstract-parsing residual for #13242 and make the merge decision, or identify any remaining requirement?

@Git-on-my-level

Copy link
Copy Markdown
Member

Re-verified final head e13a596: the plugin tree (main.py, test_main.py, README.md, test_clean.py) is byte-identical to the state @kodjima33 approved, so the merge updates introduced no new plugin code. The only delta on this head is the checks-manifest conflict resolution, and it resolves cleanly against current main — exactly the +5-line crossref-abstract-tests entry (local and ci lanes, plugins/omi-crossref-app/** trigger), nothing else added or dropped.

I re-ran the hermetic handler suite against the exact head sources in a standard-library-only sandbox: 8/8 pass, and upstream test_clean.py's four assertions still pass against the retained regex clean().

With all nine workflows green on this head, I have no remaining automation-side requirement — the merge call for the #13242 residual parsing behavior stays with a human maintainer, per your last note. Thanks for keeping the branch current through three main merges and for the precise CI tracking.


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

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

Real follow-on fix to #13525: current main's clean() does html.unescape before regex tag-stripping, mishandling escaped entities/CDATA/paragraph boundaries in Crossref abstracts. New HTMLParser-based clean_abstract() is well-tested and scoped. Backend/community, confidence 5/5.

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

Follow-up fix for #13242: markup-aware abstract parser with comprehensive test coverage (CDATA, escaped entities, inline tags, truncation on visible text). Verified not a duplicate of the connection-pooling PRs (#13979/#13985) targeting a different issue. Confidence 5/5.

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

Verified on e13a59656454.

Head is CONFLICTING/DIRTY, so this cannot merge even with kodjima APPROVE. Rebase onto current main and keep the diff on .github/checks-manifest.yaml, plugins/omi-crossref-app/README.md, plugins/omi-crossref-app/main.py, plugins/omi-crossref-app/test_main.py.

kodjima size-gate APPROVE is not a maintainer merge. I am not merging until this is MERGEABLE and green.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Crossref clean() still unescapes before it strips tags, so an escaped literal tag disappears. e13a59656454 is DIRTY against the current import block. Rebase before approval.

— Astar, on behalf of @aryanorastar

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving e13a59656454. origin/main plugins/omi-crossref-app/main.py clean() runs html.unescape before tag stripping. This SHA parses with clean_abstract before entity decode. Hygiene SUCCESS. Complementary to the {exc} mask on the same file in other open PRs. mergeable CONFLICTING/DIRTY.

— Astar, on behalf of @aryanorastar

@aryanorastar

Copy link
Copy Markdown
Collaborator

Closing. This is already on main via #13525. Not merged.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @kaijakagi-sys 👋

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!

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.

4 participants