feat(project-graph): activate semantic extraction on email import (flag-gated)#927
Closed
seonghobae wants to merge 1 commit into
Closed
feat(project-graph): activate semantic extraction on email import (flag-gated)#927seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
…agged) Wires the existing-but-dead project semantic graph pipeline into the import path: after an imported email commits, its content segments are projected into project_graph_objects via extract_project_semantics + persist_project_graph_ projection. This makes the projects /candidates surface return real data instead of an empty store. Safety: - Gated behind PROJECT_GRAPH_EXTRACTION_ENABLED (default False) -> zero change to existing import behavior until explicitly enabled. - Best-effort: runs AFTER the email is committed, wrapped in try/except with rollback, so a projection failure never fails the email import. - Segments are snapshotted before commit (in-memory, no async lazy-load) to avoid MissingGreenlet; persistence runs after commit when segments have ids. - Workspace scope uses the repository's convention (workspace-<org_id>, or workspace-<user_id> without an org). Tests (tests/test_project_graph_import_wiring.py, 6): real deterministic extractor + mocked persistence — mapping, workspace scoping (org + user fallback), no-op on empty/no-objects, and best-effort rollback on failure. Existing import + project-graph suites unaffected (56 passed). This is Phase 1 of docs/plans/2026-07-06-ai-moat-project-graph-activation.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RkKdtHRLG4wSLh6PVsp8J
| import pytest | ||
| from unittest.mock import AsyncMock | ||
|
|
||
| import services.email_import_service as import_service |
Contributor
|
PR governance metadata gate is not ready for
|
Contributor
Author
|
Folded into #931, which is now retargeted to |
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.
What
Turns the dead project-semantic-graph pipeline into a live one. The content-graph substrate is already built on every import (
email_import_service.pypersistsContentSegmentRecord), and the projects API + correction endpoint already read/annotateproject_graph_objects— but nothing populated them (extract_project_semantics/persist_project_graph_projectionhad zero non-test callers). This wires extract→persist into the import path so/candidatesreturns real data.This is Phase 1 of
docs/plans/2026-07-06-ai-moat-project-graph-activation.md(#925) — the #1 AI-moat gap.Safety (why this is low-risk despite touching the import path)
PROJECT_GRAPH_EXTRACTION_ENABLED(defaultFalse) → zero behavior change until explicitly enabled per environment.try/except+ rollback, so a projection failure never fails the email import.MissingGreenlet); persistence runs after commit when segments have ids (the FK the repository needs).workspace-<org_id>, orworkspace-<user_id>without an org) — verified by_validate_segment_scope.Tests
tests/test_project_graph_import_wiring.py(6, using the real deterministic extractor + mocked persistence): segment mapping, workspace scoping (org + user fallback), no-op on empty/no-objects, and best-effort rollback on failure. Existing import + project-graph suites unaffected — 56 passed locally (pytest tests/test_import_fixtures.py tests/test_project_graph_api.py tests/test_emails_api.py).Follow-ups (separate PRs, per the plan)
source_segment_uidscitations.apply_project_graph_correctioncorrections into a per-tenant eval set + calibrated confidence.🤖 Generated with Claude Code