Skip to content

[comp] Production Deploy#3360

Merged
tofikwest merged 3 commits into
releasefrom
main
Jul 6, 2026
Merged

[comp] Production Deploy#3360
tofikwest merged 3 commits into
releasefrom
main

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

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

  • Bug Fixes
    • findSimilarTasks: enumerate task_${org}_* via range (include vectors), rank with cosineToUnitScore, sort desc, then apply topK.
    • Added cosineToUnitScore using (1 + cos) / 2 with a zero-vector guard.
    • Cursor pagination across org task vectors; fallback to raw id when metadata.sourceId is missing.
    • Renamed pagination constants to TASK_VECTOR_*; reused in orphan sweep with no behavior change.
    • Policy PDFs (app + API): keep headings with their section via 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.

Review in cubic

github-actions Bot and others added 2 commits July 6, 2026 20:47
…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>
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app (staging) Ready Ready Preview, Comment Jul 6, 2026 9:19pm
comp-framework-editor (staging) Ready Ready Preview, Comment Jul 6, 2026 9:19pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal (staging) Skipped Skipped Jul 6, 2026 9:19pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

* 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>
@vercel vercel Bot temporarily deployed to staging – portal July 6, 2026 21:16 Inactive
@tofikwest tofikwest merged commit f76a50c into release Jul 6, 2026
13 checks passed
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.98.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants