DEV Community

Cover image for GSoC'26_Week10 : Stricter Types, PR Merged
Harkeerat Singh
Harkeerat Singh

Posted on

GSoC'26_Week10 : Stricter Types, PR Merged

Week 10 of my Google Summer of Code journey with CircuitVerse (July 27th to August 2nd) was all about getting back on track.

Last week was a little slow because I was travelling back to college and setting everything up again. As soon as this week started, I wanted to catch up and finally turn the type-safety discussion from Week 9 into actual code.


๐Ÿ›ก๏ธ Making the Pipeline More Type-Safe

I spent the start of the week researching how to make the types stricter.
The main refactor ended up being:

  • ๐Ÿงฉ Moving the canonical data contracts into a dedicated canonical.types.ts file.
  • ๐Ÿ”Œ Replacing loose WireNode / CVScope style structures with the real simulator Node and Scope types wherever possible.
  • ๐Ÿงฑ Defining proper shared types such as CanonicalProject, CanonicalScope, CanonicalComponent, CanonicalNet, CanonicalLayout and component property types.
  • ๐ŸŽฏ Keeping the truly dynamic component lookup at one documented boundary instead of letting unknown and type assertions spread through the whole pipeline.
  • ๐Ÿ—๏ธ Adding typed component-constructor handling so the importer can dynamically rebuild components without falling back to any.

The main idea was pretty simple: if the pipeline already knows the shape of something, TypeScript should know it too.

On July 29th, I raised PR #1173 with this refactor.


๐Ÿค– PR Review

Soon after opening the PR, CodeRabbit caught something much more interesting than a normal type issue.

The comparator inside canonicalSort was using interface order for some component pairs and structural fingerprints for others. That meant the comparison was not a proper total order and, in some cases, sorting could depend on the original array order.

For a normal application that might just look like a sorting bug. For a canonical format, that is dangerous because component IDs, net IDs and eventually the canonical hash all depend on deterministic ordering.

The fix was to make the rule consistent:

๐Ÿง  Compare the structural fingerprint first. Only when the fingerprints are equal, use the interface order as the tie-breaker.

I updated the comparator and also cleaned up a few unsafe non-null assumptions around wire-port and routing lookups.

CodeRabbit marked the issue as addressed after the follow-up commit. ๐ŸŽ‰

After the review fixes, PR #1173 was merged later this week!

GitHub showing CircuitVerse PR #1173 merged after review fixes


๐Ÿ”ฎ What's Next

Next week, Iโ€™ll start working on tests and see how the canonical pipeline holds up on more real circuits.

Back on track. Time to test! ๐Ÿงชโšก

Top comments (0)