forked from microsoft/graphrag
-
Notifications
You must be signed in to change notification settings - Fork 10
Add community and covariate records for pipeline parity #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KSemenenko
merged 8 commits into
main
from
codex/install-dotnet9-and-review-graphrag-project
Oct 30, 2025
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
84a921f
Add community and covariate records for pipeline parity
KSemenenko 966b7ba
Add community clustering workflow and covariate joiner
KSemenenko 4150c3c
Enable prompt tuning overrides and document alignment
KSemenenko 41b4f36
refactoring
KSemenenko a5c8dac
tests
KSemenenko acb8207
no cosmos
KSemenenko dc5d14d
tests
KSemenenko 7288f4e
readme
KSemenenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using System.Collections.Immutable; | ||
|
|
||
| namespace GraphRag.Community; | ||
|
|
||
| /// <summary> | ||
| /// Represents a finalized community row emitted by the GraphRAG pipeline. | ||
| /// </summary> | ||
| public sealed record CommunityRecord( | ||
| string Id, | ||
| int HumanReadableId, | ||
| int CommunityId, | ||
| int Level, | ||
| int? ParentId, | ||
| ImmutableArray<int> Children, | ||
| string Title, | ||
| ImmutableArray<string> EntityIds, | ||
| ImmutableArray<string> RelationshipIds, | ||
| ImmutableArray<string> TextUnitIds, | ||
| string? Period, | ||
| int Size); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| namespace GraphRag.Covariates; | ||
|
|
||
| /// <summary> | ||
| /// Represents a finalized covariate (claim) row emitted by the GraphRAG pipeline. | ||
| /// </summary> | ||
| public sealed record CovariateRecord( | ||
| string Id, | ||
| int HumanReadableId, | ||
| string CovariateType, | ||
| string? Type, | ||
| string? Description, | ||
| string SubjectId, | ||
| string? ObjectId, | ||
| string? Status, | ||
| string? StartDate, | ||
| string? EndDate, | ||
| string? SourceText, | ||
| string TextUnitId); |
40 changes: 40 additions & 0 deletions
40
tests/ManagedCode.GraphRag.Tests/Community/CommunityRecordTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| using System.Collections.Immutable; | ||
| using System.Linq; | ||
| using GraphRag.Community; | ||
| using Xunit; | ||
|
|
||
| namespace ManagedCode.GraphRag.Tests.Community; | ||
|
|
||
| public sealed class CommunityRecordTests | ||
| { | ||
| [Fact] | ||
| public void Constructor_PopulatesAllProperties() | ||
| { | ||
| var record = new CommunityRecord( | ||
| Id: "community-uuid", | ||
| HumanReadableId: 12, | ||
| CommunityId: 42, | ||
| Level: 3, | ||
| ParentId: 7, | ||
| Children: ImmutableArray.Create(8, 9), | ||
| Title: "Energy Sector", | ||
| EntityIds: ImmutableArray.Create("entity-1", "entity-2"), | ||
| RelationshipIds: ImmutableArray.Create("rel-1"), | ||
| TextUnitIds: ImmutableArray.Create("unit-1", "unit-2"), | ||
| Period: "2024-05-01", | ||
| Size: 18); | ||
|
|
||
| Assert.Equal("community-uuid", record.Id); | ||
| Assert.Equal(12, record.HumanReadableId); | ||
| Assert.Equal(42, record.CommunityId); | ||
| Assert.Equal(3, record.Level); | ||
| Assert.Equal(7, record.ParentId); | ||
| Assert.Equal(new[] { 8, 9 }, record.Children.ToArray()); | ||
| Assert.Equal("Energy Sector", record.Title); | ||
| Assert.Equal(new[] { "entity-1", "entity-2" }, record.EntityIds.ToArray()); | ||
| Assert.Equal(new[] { "rel-1" }, record.RelationshipIds.ToArray()); | ||
| Assert.Equal(new[] { "unit-1", "unit-2" }, record.TextUnitIds.ToArray()); | ||
| Assert.Equal("2024-05-01", record.Period); | ||
| Assert.Equal(18, record.Size); | ||
| } | ||
| } | ||
38 changes: 38 additions & 0 deletions
38
tests/ManagedCode.GraphRag.Tests/Covariates/CovariateRecordTests.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using GraphRag.Covariates; | ||
| using Xunit; | ||
|
|
||
| namespace ManagedCode.GraphRag.Tests.Covariates; | ||
|
|
||
| public sealed class CovariateRecordTests | ||
| { | ||
| [Fact] | ||
| public void Constructor_PopulatesAllProperties() | ||
| { | ||
| var record = new CovariateRecord( | ||
| Id: "cov-1", | ||
| HumanReadableId: 5, | ||
| CovariateType: "claim", | ||
| Type: "fraud", | ||
| Description: "Alleged false reporting", | ||
| SubjectId: "entity-1", | ||
| ObjectId: "entity-2", | ||
| Status: "SUSPECTED", | ||
| StartDate: "2024-03-01", | ||
| EndDate: "2024-04-01", | ||
| SourceText: "Entity-1 may have misled Entity-2", | ||
| TextUnitId: "unit-1"); | ||
|
|
||
| Assert.Equal("cov-1", record.Id); | ||
| Assert.Equal(5, record.HumanReadableId); | ||
| Assert.Equal("claim", record.CovariateType); | ||
| Assert.Equal("fraud", record.Type); | ||
| Assert.Equal("Alleged false reporting", record.Description); | ||
| Assert.Equal("entity-1", record.SubjectId); | ||
| Assert.Equal("entity-2", record.ObjectId); | ||
| Assert.Equal("SUSPECTED", record.Status); | ||
| Assert.Equal("2024-03-01", record.StartDate); | ||
| Assert.Equal("2024-04-01", record.EndDate); | ||
| Assert.Equal("Entity-1 may have misled Entity-2", record.SourceText); | ||
| Assert.Equal("unit-1", record.TextUnitId); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
System.Linqimport is unnecessary. The.ToArray()method used in the tests is available onImmutableArray<T>without this import. Consider removing it for cleaner code.