Skip to content

fix(insights): preserve canonical replies before public pages - #771

Merged
izadoesdev merged 1 commit into
stagingfrom
codex/context-reply-priority
Sep 9, 2026
Merged

fix(insights): preserve canonical replies before public pages#771
izadoesdev merged 1 commit into
stagingfrom
codex/context-reply-priority

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 9, 2026

Copy link
Copy Markdown
Member

Four full public-page excerpts could consume the shared context budget before a current canonical team reply reached investigation selection. Shared-profile reconciliation now merges canonical replies ahead of additional public pages; exact-subject recall retains its existing relevance ordering.

The production loadWebsiteBusinessProfile regression injects four 4,000-character public pages, a current canonical reply, and a small saved brief. It failed before the fix because the reply disappeared, and now verifies the complete reply, saved brief, homepage and two additional pages survive within the existing 16,000-character budget.

Scope: finding 2 only; two files, 37 added lines (5 implementation, 32 regression). No prompt, selector, coverage-planner, shared AI helper or evaluation-harness changes. Based on origin/staging at 4422cd61d5faa66ee9a40da23f5569e571b12078, with no unmerged dependency. Known overlap: #751 also changes the context loader and budget tests; coordinate its integration after this bounded fix. The parent's selector/evaluation work remains separate.

Validation:

  • The new regression failed before the implementation change and passes afterward.
  • bun test apps/insights/src/business-context.test.ts apps/insights/src/business-context-generation.test.ts apps/insights/src/business-aware-selection.test.ts: 56 passed.
  • In packages/ai, bun test src/lib/business-context.test.ts: 10 passed, 1 gated DB integration test skipped.
  • Root bun run lint: passed, including 14 policy tests.
  • Root bun run check-types: passed, 33 tasks (32 cached, the changed Insights package checked fresh).
  • The repository pre-push hook also passed root bun run test: 27 tasks (26 cached); Insights ran fresh with 580 passed, 6 live-model tests skipped, and 0 failures.
  • git diff --check: passed.

Validation ran with a clean environment and automatic env-file loading disabled. The first combined test attempt encountered an unbuilt SDK export after 37 passing tests; after the root type-check build supplied the SDK artifact, the full relevant test command passed. No live LLM or production database was used.

Keep draft and do not merge until parent review and its independent fresh selector comparison. AI-assisted implementation and validation; no human verification is claimed.


Summary by cubic

Fixes shared-profile context reconciliation so a current canonical team reply survives ahead of full public-page excerpts, instead of being dropped when four 4,000-character pages consume the 16,000-character budget. The fix applies only when no subject key is provided; exact-subject recall keeps its existing relevance ordering.

Bug Fixes

  • Canonical replies now merge before shared public pages when no subject key is set.
  • Adds a regression test covering the four-page scenario and asserting the reply, saved brief, homepage, and two pages fit within budget.
  • Coordinate with feat(insights): persist complete business context and reusable briefs #751, which also changes the context loader and budget tests, after this fix lands.

Written for commit c6e0994. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Sep 9, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
databuddy-status Ready Ready Preview Sep 9, 2026 12:12am UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Sep 9, 2026 12:12am UTC
documentation Skipped Skipped Sep 9, 2026 12:12am UTC

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 5c64046a-b1fd-41de-bac1-c109e0eb8033

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@izadoesdev
izadoesdev marked this pull request as ready for review September 9, 2026 00:22
@izadoesdev
izadoesdev merged commit 8c43be0 into staging Sep 9, 2026
18 checks passed
@izadoesdev
izadoesdev deleted the codex/context-reply-priority branch September 9, 2026 00:22
@greptile-apps

greptile-apps Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes shared-profile reconciliation so eligible canonical team replies are selected before additional public-page excerpts when no subject key is provided.

  • Preserves the existing exact-subject relevance path.
  • Adds a regression test covering four large public pages, a canonical reply, and a saved organization profile within the context budget.
  • Keeps bounded-context status and source ordering expectations explicit.

Confidence Score: 5/5

The PR appears safe to merge because the ordering change is bounded to shared-profile reconciliation and the regression test verifies the intended budget behavior.

No actionable failures remain; exact-subject recall is unchanged, canonical replies gain the intended priority, and saved-profile, status, issue, and budget behavior remain consistent.

Important Files Changed

Filename Overview
apps/insights/src/business-context.ts Reorders no-subject reconciliation so canonical replies consume the shared context budget before additional public pages.
apps/insights/src/business-context.test.ts Adds a focused regression proving the complete canonical reply, saved profile, and expected website pages survive bounded selection.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Load shared website context] --> B[Read eligible canonical replies]
    B --> C{Subject key present?}
    C -- No --> D[Merge canonical replies before public pages]
    C -- Yes --> E[Keep exact-subject relevance ordering]
    D --> F[Merge saved organization profile]
    E --> F
    F --> G[Apply bounded context selection]
Loading

Reviews (1): Last reviewed commit: "fix(insights): preserve canonical replie..." | Re-trigger Greptile

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