Skip to content

fix: Fix Cyclical Loop Via Traversal Expansion Errors - BED-8955 - #115

Open
LawsonWillard wants to merge 2 commits into
mainfrom
BED-8955
Open

fix: Fix Cyclical Loop Via Traversal Expansion Errors - BED-8955#115
LawsonWillard wants to merge 2 commits into
mainfrom
BED-8955

Conversation

@LawsonWillard

@LawsonWillard LawsonWillard commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • Adds a new connect-local function to dawgsrun to easily enable start up for devs
  • Fixes cyclical PGSQL traversal expansion
  • Adds new unit/integration tests for self and cyclical loops
  • Fixes a bug in the neo4j driver where the full path was not returning correctly for cycles

Resolves: BED-8955

Type of Change

  • Bug fix (a change that fixes an issue)
  • Build / CI / tooling

Testing

  • Integration tests added / updated
  • Full test suite run (make test_all with CONNECTION_STRING set)

Driver Impact

  • PostgreSQL driver (drivers/pg)
  • Neo4j driver (drivers/neo4j)

Checklist

  • Code is formatted
  • All existing tests pass
  • go.mod / go.sum are up to date if dependencies changed

Summary by CodeRabbit

  • New Features

    • Added a connect-local command to quickly connect to the default local database and initialize the default graph.
    • Added support for an optional connection name.
  • Bug Fixes

    • Improved graph query handling for self-loop expansions, including correct node matching and projection constraints.
  • Documentation

    • Added usage instructions and examples for connect-local.
  • Tests

    • Added comprehensive coverage for self-cycles across multiple lengths, edge types, and query patterns.

@LawsonWillard LawsonWillard self-assigned this Aug 11, 2026
@LawsonWillard LawsonWillard added the bug Something isn't working label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 92d29bfb-a9c7-4329-85c8-d463fcc3cfb3

📥 Commits

Reviewing files that changed from the base of the PR and between a6c8bb8 and f6ec7f7.

📒 Files selected for processing (3)
  • drivers/neo4j/node.go
  • drivers/neo4j/node_internal_test.go
  • integration/testdata/self_cycles.md

Walkthrough

The PostgreSQL translator now supports self-loop expansions. Neo4j path reconstruction preserves cyclic traversal order. Integration fixtures cover self-cycle queries. dawgrun adds connect-local. Repository metadata and dependency versions are updated.

Changes

Self-loop expansion and path reconstruction

Layer / File(s) Summary
Self-loop projection handling
cypher/models/pgsql/translate/expansion.go, integration/testdata/self_cycles.json, integration/testdata/cases/self_cycles.json, integration/testdata/self_cycles.md
Self-loop expansions use one node join and matching endpoint IDs. Fixtures and cases cover typed, untyped, fixed-length, variable-length, and mixed-edge cycles.
Neo4j cyclic path reconstruction
drivers/neo4j/node.go, drivers/neo4j/node_internal_test.go
newPath follows relationship endpoints to rebuild paths with repeated nodes and reverse relationship traversal. Tests cover cycles, self-loops, and path ordering.

Local database connection command

Layer / File(s) Summary
Register and document connect-local
tools/dawgrun/pkg/commands/db.go, tools/dawgrun/pkg/commands/registry.go, tools/dawgrun/README.md
The command opens the default local PostgreSQL instance, initializes the default graph, supports an optional connection name, and has usage documentation.

Repository metadata updates

Layer / File(s) Summary
Update repository metadata
.gitignore, go.mod
.augment/ is ignored. Direct and indirect golang.org/x dependencies are updated.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CommandRegistry
  participant connectLocalCmd
  participant openConnection
  participant LocalPostgreSQL
  User->>CommandRegistry: invoke connect-local
  CommandRegistry->>connectLocalCmd: resolve command
  connectLocalCmd->>openConnection: pass local credentials and graph initialization
  openConnection->>LocalPostgreSQL: open connection
  LocalPostgreSQL-->>User: return initialized connection
Loading

Possibly related PRs

Poem

I hop through loops with one neat join,
And trace each path from point to point.
A local command opens the way,
While graphs cycle through the day.
The rabbit checks each edge tonight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: fixing cyclical loop errors in traversal expansion, and it includes the related issue number.
Description check ✅ Passed The description covers the change, issue, change types, testing, driver impact, and checklist; the unit-test checkbox is not selected despite added unit tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BED-8955

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tools/dawgrun/README.md (1)

143-144: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use fenced code blocks for the new command examples.

Because markdownlint-cli2 reports MD046 at Line 143 and Line 149, convert both indented examples to fenced code blocks. This removes the lint warnings without changing the rendered content.

Proposed documentation fix
-    dawgrun > connect-local
-    Opened pg connection 'local'
+```console
+dawgrun > connect-local
+Opened pg connection 'local'
+```

-    dawgrun > connect-local dev
-    Opened pg connection 'dev'
+```console
+dawgrun > connect-local dev
+Opened pg connection 'dev'
+```

Also applies to: 149-150

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/dawgrun/README.md` around lines 143 - 144, Convert both indented
command examples in the README, including the connect-local examples, to fenced
console code blocks while preserving their content and rendered output.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tools/dawgrun/README.md`:
- Around line 143-144: Convert both indented command examples in the README,
including the connect-local examples, to fenced console code blocks while
preserving their content and rendered output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7f1502d-27d6-415f-afa1-7d618fd1032c

📥 Commits

Reviewing files that changed from the base of the PR and between 7e219be and a6c8bb8.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • .gitignore
  • cypher/models/pgsql/translate/expansion.go
  • go.mod
  • integration/testdata/cases/self_cycles.json
  • integration/testdata/self_cycles.json
  • tools/dawgrun/README.md
  • tools/dawgrun/pkg/commands/db.go
  • tools/dawgrun/pkg/commands/registry.go

),
)
}
if previousProjectionFrameID != "" && traversalStep.RightNodeBound {

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.

I don't know if this is worth handling here or as a follow-on in another ticket, but if a self-loop is matched in a later frame and is using new bindings that are not exported in the previous frame (for example, match (x) match (n)-[*..]->(n) return n), this endpoint-binding gate will try to reference the right-side identifier through the previous frame and blow up:

dawgrun > query-cypher bloodhound 'MATCH (x) MATCH (n)-[*..]->(n) return n limit 10'
query-cypher failed: error running cypher query 'MATCH (x) MATCH (n)-[*..]->(n) return n limit 10': ERROR: column s0.n1 does not exist (SQLSTATE 42703)

defaultPGConnectionString = "postgres://dawgs:weneedbetterpasswords@localhost:65432/dawgs?sslmode=disable"
)

func connectLocalCmd() CommandDesc {

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.

i love this! could also be neat to accept a path to a bloodhound clone to read the local-harnesses/build.config.json and create a connection from it

@AD7ZJ AD7ZJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I did some testing locally and it's working fine for me! Good job figuring that out 🤯 I had some fun trying to understand all of this!

@urangel urangel 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.

Checks out for me! 🚀

image

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants