Skip to content

Fix phrase chunk subdoc schema and refactor bundle suggestion RPC #86exnxbwb#38

Merged
navidshad merged 2 commits into
devfrom
CU-86exnxbwb_Step-6-Build-PRFAQ-001-Phase-1-Productive-Retrieval-Smart-Review_Navid-Shad
May 24, 2026
Merged

Fix phrase chunk subdoc schema and refactor bundle suggestion RPC #86exnxbwb#38
navidshad merged 2 commits into
devfrom
CU-86exnxbwb_Step-6-Build-PRFAQ-001-Phase-1-Productive-Retrieval-Smart-Review_Navid-Shad

Conversation

@navidshad
Copy link
Copy Markdown
Contributor

@navidshad navidshad commented May 24, 2026

🏷️ PR Title: Fix phrase chunk subdoc schema and refactor bundle suggestion RPC

📋 Summary

This PR fixes the chunk subdocument schema related to phrase and translation matching, improving token headroom handling. It also refactors the bundle suggestion feature by implementing a dedicated per-page RPC and removing it from the translation path.

🔗 Related Tasks

#50af640 - Fix chunk subdoc schema, match-by-phrase, token headroom
#9922825 - Refactor bundle suggestion: dedicated per-page RPC, off the translation path

📝 Additional Details

The changes improve schema accuracy for phrase translation handling and optimize the bundle suggestion RPC architecture for better modularity and performance.

📜 Commit List

50af640 Fix phrase chunk subdoc schema, match-by-phrase, token headroom
9922825 Refactor bundle suggestion: dedicated per-page RPC, off the translation path

navidshad and others added 2 commits May 21, 2026 21:05
…ion path

The bundle-name suggestion was piggy-backed on getDetailedTranslation, so it
ran on every word lookup (incl. anonymous users). Move it to its own call:

- New phrase_bundle RPC getBundleSuggestionForPage (user_access): matches an
  existing bundle by normalised source URL, else asks the model for a short
  name from the page title. Best-effort; never blocks saving.
- Remove pageTitle/pageUrl from translateWithContext + getDetailedTranslation
  and suggested_bundle_name from the translation schema/prompt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…headroom

- Fix Mongoose reserved-key collision: chunks were defined with a bare `type`
  field, so the array was treated as [String] and rejected objects (E11000-style
  cast error). Use a dedicated chunk sub-schema with the verbose `{ type }` form.
- getBundleSuggestionForPage: if the suggested name already matches a bundle,
  return it as matchedBundle so the client preselects it instead of recreating.
- createPhrase dedup now matches by phrase + type (+ owner), not translation —
  the AI returns a different translation each call, which caused duplicate docs
  and made an already-saved phrase look unsaved.
- Raise max_tokens (detailed translation 700->2000, advisor 400->800): the
  richer per-chunk definition + transliteration overflowed and truncated the
  JSON ("unterminated string") in token-heavy target languages like Persian.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@navidshad
Copy link
Copy Markdown
Contributor Author

@navidshad navidshad changed the title Cu 86exnxbwb step 6 build prfaq 001 phase 1 productive retrieval smart review navid shad Fix phrase chunk subdoc schema and refactor bundle suggestion RPC #86exnxbwb May 24, 2026
@navidshad navidshad merged commit 4fe8b09 into dev May 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant