Conversation
…red ANN (#3359) Draft treatment plans returned "0 tasks and 0 controls" because findSimilarTasks issued a metadata-filtered ANN query (organizationId AND sourceType = "task") against a single 180k+ vector shared-namespace index. Upstash applies metadata filters during approximate HNSW traversal, so a highly selective per-org filter makes the traversal exhaust its candidate budget on nearer, non-matching vectors before reaching the org's tasks — returning 0 candidates even at topK=1000 when relevant tasks exist. It gets worse as the shared index grows. An org holds at most low-hundreds of tasks, so enumerate the org's task vectors by their `task_${org}_` id prefix and score them exactly in-process. This is the right-sized tool at this scale: no recall loss, no data migration. Controls are derived from the suggested tasks, so restoring task recall restores both. Scores use `(1 + cos) / 2` to match Upstash's COSINE score scale, so the downstream department boost / threshold in linkSuggestions and the reranker's cosineScore hint are unchanged. Verified end-to-end against production data. Isolated to findSimilarTasks; the orphan prune and in-scope filtering in runLinkage are unchanged and still compose correctly. Fixes CS-681 Claude-Session: https://claude.ai/code/session_014LMSrxyX5U6gz8QZqJAGhc Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
* fix(policies): keep PDF headings with their section (CS-704) Policy PDF exports orphaned section headings at the bottom of a page while the body flowed to the next page. Both shared generators only checked that the heading line itself fit before rendering it — there was no keep-together logic, so a heading could land on the last line of a page. Before rendering a heading, reserve room for the heading PLUS the first few lines of the following section (HEADING_KEEP_WITH_LINES); if that doesn't fit, push the whole heading to the next page. The reserve accounts for each generator's actual cursor advancement (the app's per-line lineHeight checks vs. the API renderer's DEFAULT_BREAK_SPACE look-ahead) and only applies when content actually follows the heading, so a trailing heading isn't bumped to a page of its own. Heading lines now also render without per-line page-break checks, so a multi-line heading can no longer be split across pages. Applied to both: - apps/app/src/lib/pdf-generator.ts (single-policy in-app export) - apps/api/src/trust-portal/policy-pdf-renderer.service.ts (full policy-pack export in-app and via the Trust Portal) Adds a regression test that sweeps headings across page boundaries and asserts none are separated from the first line of their section. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013q6YNeuzKbUdX4yZ3yTnZk * fix(policies): address cubic review on heading keep-together Two issues raised by cubic on the CS-704 keep-together change: 1. hasFollowingContent only checked array position, so a heading followed only by empty paragraphs or hard breaks (common trailing nodes in TipTap docs) still reserved keep-together space and could be bumped to a lonely page — defeating the trailing-heading guard. Now checks whether any following sibling renders visible text (hasRenderableTextAfter). Applied to both the app and API generators. 2. The API heading render loop dropped per-line page-break checks, so a pathological heading wrapping past a full page would overflow the bottom margin instead of paginating. Restored a per-line check as a safety net; the up-front keep-together reserve means normal headings never trip it, so they still can't be split across pages. Adds regression tests for both (verified failing without the fixes). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013q6YNeuzKbUdX4yZ3yTnZk * fix(policies): cover tables + oversized headings in keep-together (cubic) Second cubic pass on the CS-704 change raised two more edge cases: 1. The keep-together reserve was a fixed text-only slab, so a heading immediately followed by a table with a tall first row (or by leading hard breaks) could still be orphaned — the table's own per-row page-break fires after the heading already committed. Replaced the position/text check with sectionLeadHeight(), which measures what the following section actually needs: a few text lines, a table's first-row height, or 0 for a trailing heading (skipping empty paragraphs and hard breaks). 2. An oversized heading (wrapping past a full page) could emit a blank leading page: requiredHeight exceeded the usable page height, so the up-front checkPageBreak added a page while the current one was still empty. Capped requiredHeight to the usable page height; the per-line loop paginates the heading across pages instead. Applied to both generators (app + API). Adds regression tests for a heading-before-tall-table and the blank-page guard (both verified failing without the fixes). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013q6YNeuzKbUdX4yZ3yTnZk --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
🎉 This PR is included in version 3.98.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automated pull request to release the candidate branch into production, which will trigger a deployment.
It was created by the [Production PR] action.
Summary by cubic
Restores task suggestions by ranking tasks per org with exact in-process cosine, and stops orphaned headings in policy PDFs by keeping headings with the start of their section. Fixes zero-result draft plans (CS-681) and improves PDF pagination across app and API (CS-704).
findSimilarTasks: enumeratetask_${org}_*viarange(include vectors), rank withcosineToUnitScore, sort desc, then applytopK.cosineToUnitScoreusing (1 + cos) / 2 with a zero-vector guard.metadata.sourceIdis missing.TASK_VECTOR_*; reused in orphan sweep with no behavior change.HEADING_KEEP_WITH_LINES; reserve space for body lines or a following table’s first row; skip empty trailing nodes; cap reserve to page height and paginate oversized headings; avoid blank leading pages. Regression tests added.Written for commit 5bac5c9. Summary will update on new commits.