Skip to content

Implement OSPF control plane and dynamic routing - #2

Merged
jojo-swe merged 6 commits into
mainfrom
agent/ospf-control-plane
Jul 18, 2026
Merged

jojo-swe merged 6 commits into
mainfrom
agent/ospf-control-plane

Conversation

@jojo-swe

Copy link
Copy Markdown
Owner

Scope

This is a real simulator feature, not a documentation-only change.

  • adds OSPF configuration types to the shared model
  • builds full adjacencies from active links, matching subnets and area configuration
  • originates deterministic router LSAs and a shared LSDB
  • runs Dijkstra SPF with interface costs and deterministic tie-breaking
  • installs OSPF routes with next hop, outgoing interface, metric and advertising router
  • integrates learned routes into forwarding with administrative-distance ordering
  • recomputes topology on demand so link deletion withdraws routes immediately
  • exposes OSPF snapshots through the World API
  • adds regression coverage for adjacency, LSDB, SPF, bidirectional forwarding, route withdrawal and area mismatch

Validation status

The branch has been submitted to GitHub Actions. I am not claiming it passes until the workflow result has been inspected.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@jojo-swe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 29cdbf92-fa0d-4185-b2c7-e9431108fe44

📥 Commits

Reviewing files that changed from the base of the PR and between 52405e7 and 15ce6d7.

📒 Files selected for processing (5)
  • apps/api/src/regression/ospf.test.ts
  • apps/api/src/sim/ospf.ts
  • apps/api/src/sim/routing.ts
  • apps/api/src/sim/world.ts
  • packages/shared/src/types.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/ospf-control-plane

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

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

@jojo-swe
jojo-swe marked this pull request as ready for review July 18, 2026 02:00
@jojo-swe
jojo-swe merged commit 03dce08 into main Jul 18, 2026
0 of 3 checks passed

@greptile-apps greptile-apps 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.

Your trial has ended. Reactivate Greptile to resume code reviews.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment thread apps/api/src/sim/ospf.ts
Comment on lines +92 to +96
const addresses = Object.values(device.config.interfaces)
.map((iface) => iface.ipv4Address)
.filter((value): value is string => Boolean(value))
.sort();
return addresses.at(-1) ?? device.id;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Automatically chosen router identifier picks the wrong address

The router identifier is derived by sorting interface addresses as plain text (.sort() at apps/api/src/sim/ospf.ts:95) and taking the last one, instead of the numerically highest address, so a router without an explicitly configured identifier can advertise itself under the wrong identity.

Impact: When no router-id is configured, a device may present a router identity that does not match real-device behavior (highest IP), and tie-breaking/ordering can differ from expectations, hurting fidelity and reproducibility.

Why lexicographic sort mis-orders IPv4 addresses

stableRouterId (apps/api/src/sim/ospf.ts:88-97) collects ipv4Address values and calls .sort() (default string comparison) then .at(-1). String order treats each octet character-by-character, so e.g. ["192.168.1.20", "192.168.1.3"] sorts to ["192.168.1.20", "192.168.1.3"] and returns 192.168.1.3, whereas OSPF selects the numerically highest (192.168.1.20). This only triggers when config.ospf.routerId is undefined (allowed by configureOspf at apps/api/src/sim/world.ts:174). CONTRIBUTING.md's "Fidelity Over Convenience" and determinism rules make correct highest-IP selection the expected behavior.

Prompt for agents
In stableRouterId (apps/api/src/sim/ospf.ts:88-97), the fallback router-id selection sorts interface IPv4 addresses lexicographically with .sort() and takes the last element. This does not select the numerically highest IPv4 address the way OSPF does (e.g. 192.168.1.20 should beat 192.168.1.3, but string sort picks 192.168.1.3). Convert each address to its integer form (ipv4ToInt is available in @netsim/shared) and pick the address with the maximum integer value, so the auto-derived router identifier matches real-device behavior and stays deterministic.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant