Skip to content

feat(email-writing): build authorized thread context - #1329

Draft
seonghobae wants to merge 8 commits into
feat/llm-email-writing-review-evidence-task3from
feat/llm-email-writing-context-task4
Draft

feat(email-writing): build authorized thread context#1329
seonghobae wants to merge 8 commits into
feat/llm-email-writing-review-evidence-task3from
feat/llm-email-writing-context-task4

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Stack dependency

This Draft PR is stacked on #1328 (feat/llm-email-writing-review-evidence-task3) and implements Task 4 only from the committed LLM email-writing implementation plan.

Customer next action

This PR is context-construction only. Customers should continue to write and send email with the current editor and send path. No writing-guidance feature, language profile, or model is available in product. Writing and sending stay on the current path.

Included

  • server-authoritative selected-email lookup through Email.owner_filters(auth_context.user_id, auth_context.organization_id);
  • tenant-indistinguishable unavailable-email outcomes for missing, deleted, cross-user, and cross-organization references;
  • canonical persisted thread-key lookup with the same owner scope and defensive row revalidation;
  • immutable EmailWritingContextBundle, chronological message records, and participant-role records;
  • complete selected source, quoted material, signatures, sender/reply-to/recipient metadata, source timestamps, reply objective, current draft, and declared language tag;
  • explicit prompt trust labels separating untrusted email content from untrusted authored content;
  • deterministic complete-message selection by thread membership, chronology, review mode, recency, and size budget;
  • no string, UTF-8, grapheme, selector, or JSON truncation: oversized selected content fails closed and older related messages are omitted only as complete units with stable limitation codes;
  • canonical message de-duplication, owner/thread filtering, malformed-ID rejection, and bounded candidate/message counts;
  • recipient and reply-target roles derived solely from persisted server headers;
  • no browser-supplied thread text, participants, recipient roles, endpoint, credential, or semantic selector.

Semantic-authority boundary

The service performs authorization, thread membership, chronology, bounded context construction, recipient-role derivation, and trust labeling only. It does not decide which message is important by keywords, infer tone, quality, or actionability, use sender domains or recipient counts as semantic features, or apply nearest-text or positional fallback.

Exact-head verification

Previous head (exact current PR head at launch):

0376d0ac896f6ea86183234495184694b27d7896

GitHub last showed base feat/llm-email-writing-review-evidence-task3 at stale:

6ab000efd8ad262e3f51462ae5cfddd57d849c53

Current head (normal merge commit, not squash, not rebase, not force-push):

4570747ccebd57ccaab30ffc68239f0c9d2f1ca0

Live parent #1328 (feat/llm-email-writing-review-evidence-task3) merged as the second parent:

51fb5e8543247b1e5c790f3fdf98424c8fbed669

Normal merge commit parents:

  • first parent: 0376d0ac896f6ea86183234495184694b27d7896
  • second parent: 51fb5e8543247b1e5c790f3fdf98424c8fbed669

Live parent #1328 already contains #1327 fb7c406ee1328a6ac42dbaf54bb6852c199d8b0a / #1322 bfc2df112136bb9fe358778d701e78bf9e78b685 / develop@dd8d15191338b841f9e6f3a06507c6a5643b95d0.

ADR numbering follows the live parent:

  • calendar ADR-0004 stays unique (0004-status-weighted-calendar-conflicts.md);
  • email-writing remains ADR-0005;
  • Task 4 context files were unchanged by the merge (no product conflict, no context-semantics edit).

Local validation counts on 4570747ccebd57ccaab30ffc68239f0c9d2f1ca0:

  • authorized email/thread context tests: 18 passed (tests/test_email_writing_context_service.py)
  • context terminal-boundary / coverage tests: 14 passed (tests/test_email_writing_context_service_coverage.py)
  • combined focused context + terminal-boundary tests: 32 passed
  • parent contract sanity tests: 8 passed (tests/test_email_writing_contracts.py + tests/test_email_writing_contracts_terminal_coverage.py)
  • combined focused + parent contract tests: 40 passed
  • context coverage: 100% (254 statements, 72 branches, fail-under=100)
  • ruff: All checks passed
  • production-module compileall for the context service: ok
  • git diff --check: ok
  • conflict markers / product context-semantics edits: 0
  • stability scan: no Timeout / Fatal / Warn / Denied

Predecessor evidence does not transfer. Checks, reviews, and security evidence recorded for 0376d0ac, 6ab000ef, or any earlier head are non-passing for this head.

Merge boundary

Keep this PR Draft while #1328 and its parent stack remain unmerged. This slice does not add contextual-orchestrator transport, tenant inference credentials, model or Judge calls, prompt templates, API routes, editor UI integration, sending, publishing, or release changes. Independent review, zero actionable threads, branch protection, and exact-current-head required checks remain mandatory before merge. This update does not approve, merge, squash, empty-requeue, force-cancel, or mark Ready.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 18 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ae7f4d0d-1615-47cd-9564-57cabcb34ef4

📥 Commits

Reviewing files that changed from the base of the PR and between 51fb5e8 and 4570747.

📒 Files selected for processing (4)
  • .github/workflows/email-writing-context-tdd.yml
  • backend/services/email_writing_context_service.py
  • backend/tests/test_email_writing_context_service.py
  • backend/tests/test_email_writing_context_service_coverage.py

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.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

PR governance metadata gate is not ready for 4570747ccebd57ccaab30ffc68239f0c9d2f1ca0:

  • Draft PR: merge automation is paused.

seonghobae and others added 4 commits August 15, 2026 20:54
…idence-task3' into feat/llm-email-writing-context-task4
…idence-task3' into feat/llm-email-writing-context-task4

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@seonghobae

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review the unchanged exact current head 4570747ccebd57ccaab30ffc68239f0c9d2f1ca0 (normal merge of live parent #1328 51fb5e85). Predecessor 0376d0ac evidence does not transfer. Local Task 4: 32 focused context tests passed, 100% coverage. Keep Draft. This comment is not an approval.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@seonghobae I will review the exact current head 4570747ccebd57ccaab30ffc68239f0c9d2f1ca0. The PR remains Draft. This action does not approve or merge the PR.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

cursor Bot pushed a commit that referenced this pull request Aug 17, 2026
…ask4' into feat/llm-email-writing-orchestrator-task5

Retarget Task 5 onto live #1329 head 4570747
(merged onto live #1328 51fb5e8 / #1327 fb7c406 / #1322 bfc2df1 / develop@dd8d1519).

Preserve the hardened contextual-orchestrator boundary. Do not restore
write-capable Task 5 promotion/finalize workflows.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@opencode-agent opencode-agent Bot added area: auth Authentication, authorization, identity, or tenant isolation area: ci-cd CI, GitHub Actions, checks, release, or supply chain priority: medium Normal-priority or P2 work status: draft Draft pull request type: feature New or expanded product capability labels Aug 22, 2026
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

An error occurred during the review process. Please try again later.


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.

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

Labels

area: auth Authentication, authorization, identity, or tenant isolation area: ci-cd CI, GitHub Actions, checks, release, or supply chain priority: medium Normal-priority or P2 work status: draft Draft pull request type: feature New or expanded product capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants