Skip to content

feat(gremlin): add the projects of the core and of Azure Cosmos DB - #75

Open
xperiandri wants to merge 1 commit into
mainfrom
feat/gremlin-skeleton
Open

xperiandri wants to merge 1 commit into
mainfrom
feat/gremlin-skeleton

Conversation

@xperiandri

@xperiandri xperiandri commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This change adds the two projects of the Gremlin libraries, with the split into a core and a provider from the start:

  • src/Gremlin (FSharp.Gremlin): the core. It does not depend on a provider. A client of a TinkerPop Gremlin Server references it alone.
  • src/Cosmos.Gremlin (FSharp.Azure.Cosmos.Gremlin): Azure Cosmos DB for Apache Gremlin on top of the core.

No package is made of the two projects (IsPackable=false) until a query runs end to end. This change is independent of the first two steps (branches feat/cosmos-json-package and test/baseline-extension).

Content

  • LabelAttribute sets the label of the vertices or the edges of a record type. Without it, the label is the name of the type, as ExRam.Gremlinq writes it. Thus a graph that ExRam.Gremlinq wrote keeps its labels.
  • PartitionKeyAttribute marks the field of a vertex record that holds the partition key.
  • VertexProperty<'Value, 'Meta> is a struct record: the value of a vertex property and a record of its meta-properties. VertexProperty.create and VertexProperty.some create it.
  • CosmosGremlinConnection holds the settings of a graph. CosmosGremlinConnection.azure gives <account>.gremlin.cosmos.azure.com, port 443 and TLS. CosmosGremlinConnection.emulator gives localhost, port 8901 without TLS, and the well-known key. UserName is /dbs/<database>/colls/<graph>.

Facts from the emulator

On 2026-11-08 I connected Gremlin.Net 3.8.2 to the Windows emulator that runs with /EnableGremlinEndpoint:

  • Port 8901 accepts only ws. With wss, the TLS handshake fails. Thus emulator sets UseSsl = false.
  • The user name /dbs/<database>/colls/<graph> and the key authenticate through the SASL challenge of the server.

The key and the logs

StructuredFormatDisplay makes ToString, %A and an interpolated string of the record give Description: the endpoint and the user name, without the key. A structured logger that reads the public properties of the record writes the key. Thus the documentation tells a caller to write Description to a log, not the record.

Checks of the input

  • azure refuses an account name that does not obey the rule of Azure: 3 to 44 lowercase letters, numbers and hyphens, with a letter or a number first. Thus a host that a caller gives as an account name (myaccount.gremlin.cosmos.azure.com) fails at once. A null account name, which a caller in C# can give, fails with an ArgumentException too.
  • azure and emulator refuse an empty id, an id with /, \, ? or #, an id with more than 255 characters, and an id that ends in a space. Data Explorer refuses such an id (ValidCosmosDbIdDescription in src/Utils/ValidationUtils.ts of Azure/cosmos-explorer). I could not ask the emulator itself, because it did not run at the time.
  • azure refuses an empty key.

Tests

  • tests/Gremlin.Tests: 6 unit tests. They check that LabelAttribute is on the record type, and that F# puts the PartitionKeyAttribute of a record field on the property that it generates. The graph model of the next step reads the attribute there.
  • tests/Cosmos.Gremlin.Tests: 27 unit tests of the settings.
  • To check the tests, I planted defects: I changed the code of the settings in ten small, incorrect ways, one change at a time, and ran the tests after each change. Each change made a test fail. A first run had one more defect, which removed an override of ToString. No test failed, because the record already formats itself through StructuredFormatDisplay. Thus I removed that override.
  • The Debug build has no error and no warning in the new projects. Fantomas accepts the new files.

Review

Round 1 (Copilot): an id that ends in a space, and a documentation text that promised too much about logs. The commit has the fixes for both. I also replaced an isNull check of a string parameter, which gave a nullness warning, with String.IsNullOrEmpty.

Not in this change

The plan also lists the attributes for the id, the out-vertex and the in-vertex of an edge, and the cardinality of a property. The next step (the graph model) does without them: the id is the field named Id, and the type of a field gives its cardinality.

🤖 Generated with Claude Code

@xperiandri
xperiandri requested a balanced review from Copilot November 8, 2026 00:44
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next included review available in 45 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1696de30-1a0c-44ab-87d7-3d5a485610a9
Commits

Reviewing files that changed from the base of the PR and between ef5d60b and 757ac46.

Files selected for processing: 20

  • .github/copilot-instructions.md
  • .github/instructions/test-layout.instructions.md
  • FSharp.Azure.Cosmos.slnf
  • FSharp.Azure.Cosmos.slnx
  • src/Cosmos.Gremlin/AssemblyInfo.fs
  • src/Cosmos.Gremlin/CosmosGremlinConnection.fs
  • src/Cosmos.Gremlin/FSharp.Azure.Cosmos.Gremlin.fsproj
  • src/Gremlin/AssemblyInfo.fs
  • src/Gremlin/Attributes.fs
  • src/Gremlin/FSharp.Gremlin.fsproj
  • src/Gremlin/VertexProperty.fs
  • tests/Cosmos.Gremlin.Tests/CosmosGremlinConnectionTests.fs
  • tests/Cosmos.Gremlin.Tests/FSharp.Azure.Cosmos.Gremlin.Tests.fsproj
  • tests/Cosmos.Gremlin.Tests/TestCategories.fs
  • tests/Cosmos.Gremlin.Tests/testconfig.json
  • tests/Gremlin.Tests/FSharp.Gremlin.Tests.fsproj
  • tests/Gremlin.Tests/GraphModel/AttributeTests.fs
  • tests/Gremlin.Tests/GraphModel/VertexPropertyTests.fs
  • tests/Gremlin.Tests/TestCategories.fs
  • tests/Gremlin.Tests/testconfig.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Database and graph ID validation still accepts trailing spaces that Cosmos DB forbids, allowing both factories to construct invalid settings.

2 open issues
What changed in this PR

Adds the foundation for Gremlin support alongside the existing Cosmos library, separating provider-independent graph types from Azure Cosmos DB connection settings. Both libraries remain non-packable until end-to-end queries are supported.

Changes:

  • Introduces graph attributes and a struct-based vertex property type with meta-properties.
  • Adds Azure and emulator connection factories, input validation, and key-free display formatting.
  • Adds unit-test projects and integrates all four projects into the solution.
File Description
tests/​Gremlin.Tests/​VertexPropertyTests.fs Tests property creation, optional values, and structural equality.
tests/​Gremlin.Tests/​testconfig.json Enables method-level test parallelism.
tests/​Gremlin.Tests/​TestCategories.fs Defines the graph-model test category.
tests/​Gremlin.Tests/​FSharp.Gremlin.Tests.fsproj Configures the core unit-test project.
tests/​Gremlin.Tests/​AttributeTests.fs Tests attribute placement on records and properties.
tests/​Cosmos.Gremlin.Tests/​testconfig.json Enables method-level test parallelism.
tests/​Cosmos.Gremlin.Tests/​TestCategories.fs Defines the connection test category.
tests/​Cosmos.Gremlin.Tests/​FSharp.Azure.Cosmos.Gremlin.Tests.fsproj Configures the provider unit-test project.
tests/​Cosmos.Gremlin.Tests/​CosmosGremlinConnectionTests.fs Tests connection defaults, validation, and display formatting.
src/​Gremlin/​VertexProperty.fs Adds vertex properties with typed meta-properties and helpers.
src/​Gremlin/​FSharp.Gremlin.fsproj Defines the non-packable, provider-independent library.
src/​Gremlin/​Attributes.fs Adds label and partition-key attributes.
src/​Gremlin/​AssemblyInfo.fs Supplies core assembly metadata.
src/​Cosmos.Gremlin/​FSharp.Azure.Cosmos.Gremlin.fsproj Defines the non-packable provider library referencing the core.
src/​Cosmos.Gremlin/​CosmosGremlinConnection.fs Adds connection settings and validated Azure/emulator factories.
src/​Cosmos.Gremlin/​AssemblyInfo.fs Supplies provider assembly metadata.
FSharp.Azure.Cosmos.slnx Registers the four new projects.
FSharp.Azure.Cosmos.slnf Includes the new projects in the solution filter.
.github/​copilot-instructions.md Documents the new library and test directories.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The two GraphModel test files are placed at the project root, contrary to the required topic-folder layout, and need updated compile paths and layout documentation.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment on lines +23 to +24
<Compile Include="AttributeTests.fs" />
<Compile Include="VertexPropertyTests.fs" />
The Gremlin libraries are two packages from the start. `FSharp.Gremlin` is
the core and does not depend on a provider. `FSharp.Azure.Cosmos.Gremlin`
adds Azure Cosmos DB for Apache Gremlin. A client of a TinkerPop Gremlin
Server references the core alone.

`src/Gremlin` contains the types that a graph model declares:
`LabelAttribute`, which sets the label of a record type,
`PartitionKeyAttribute`, which marks the field that holds the partition key,
and the struct record `VertexProperty<'Value, 'Meta>`, a vertex property
with its meta-properties.

`src/Cosmos.Gremlin` contains `CosmosGremlinConnection`, the settings of a
graph: `azure` for an account in Azure (port 443 with TLS) and `emulator`
for the local emulator (port 8901 without TLS, the well-known key). On
2026-11-08 the emulator accepted only `ws` on port 8901, and the TLS
handshake of `wss` failed. `ToString`, `%A` and an interpolated string of
the settings show `Description`, which does not contain the key. `azure`
refuses an account name that does not obey the rule of Azure. The two
functions refuse an id that Cosmos DB does not allow, and an id that ends
in a space, which Data Explorer refuses.

No package is made of the two projects until a query runs end to end. Each
project has a test project: `tests/Gremlin.Tests` and
`tests/Cosmos.Gremlin.Tests`. The test layout instruction lists their
groups of test categories, so the two test files of the graph model are in
`tests/Gremlin.Tests/GraphModel/`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants