Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/ManagedCode.GraphRag/Community/CommunityRecord.cs
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);
2 changes: 2 additions & 0 deletions src/ManagedCode.GraphRag/Constants/PipelineTableNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ public static class PipelineTableNames
public const string TextUnits = "text_units";
public const string Entities = "entities";
public const string Relationships = "relationships";
public const string Communities = "communities";
public const string CommunityReports = "community_reports";
public const string Covariates = "covariates";
}
18 changes: 18 additions & 0 deletions src/ManagedCode.GraphRag/Covariates/CovariateRecord.cs
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 tests/ManagedCode.GraphRag.Tests/Community/CommunityRecordTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Collections.Immutable;
using System.Linq;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The System.Linq import is unnecessary. The .ToArray() method used in the tests is available on ImmutableArray<T> without this import. Consider removing it for cleaner code.

Suggested change
using System.Linq;

Copilot uses AI. Check for mistakes.
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);
}
}
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);
}
}
Loading