Skip to main content

The Birth of Dike: A Tale of Practical Justice

· 3 min read
Max Kaido
Architect

Today marks a significant milestone in Mercury Bot's evolution with the release of version 1.15.3, introducing Dike - our new market ranking system named after the Greek goddess of justice and fair judgment. This release represents not just a technical improvement, but a journey from theoretical perfection to practical wisdom.

The Three Paths to Order

The Path to Practical Justice

Our journey to perfect market rankings has been a tale of architectural evolution through three distinct approaches:

  1. Kairos - Immutable QuickSort: Our first attempt embraced immutability with QuickSort. Like the god of perfect moments, each comparison created a pristine snapshot of truth. The approach was theoretically elegant - each state change produced a new, immutable copy, ensuring perfect consistency. However, the cost of creating and maintaining these immutable states for each comparison became overwhelming. The divine scrolls of our Redis store filled with countless versions of truth.

  2. Hermes - Event Sourced QuickSort: Learning from Kairos, we turned to Hermes's wisdom of recording history. Instead of storing states, we recorded each comparison as an event. This event-sourcing approach promised perfect traceability - every decision was a chapter in our story. Yet as our tournaments grew, reconstructing the current state from this historical narrative became increasingly complex. The events, though perfectly preserved, created a tapestry too intricate to unravel efficiently.

Dike's Inheritance

  1. Dike - Practical Justice: Finally, we found wisdom in Dike's approach to justice. As the daughter of Themis (divine law) and Zeus (power), she knew that true justice lies not in perfect laws or complete histories, but in the practical application of fair judgment. Each comparison became a straightforward evaluation, handled with care but without the overhead of previous approaches. The result? A system that maintains order through practical wisdom rather than theoretical perfection.

The Wisdom of Dike

The birth of Dike brought several key realizations:

  1. Justice is Practical: Instead of complex state management or event sourcing, embrace direct, fair comparisons
  2. Order through Action: Clear transaction boundaries and straightforward job processing bring stability
  3. Fair Judgment: Each comparison stands on its own merit
  4. Divine Patience: Robust retry mechanisms ensure reliable evaluations

Technical Manifestation

The core wisdom of Dike manifests in her simplified judgment pipeline:

// Direct, clear, and fair judgment
for (const comparison of comparisons) {
await queue.add(
JobName.COMPARE_MARKETS,
{
comparisonId: comparison.id,
tournamentId,
roundNumber: currentRound,
itemA: comparison.itemA,
itemB: comparison.itemB,
},
{
attempts: 7,
backoff: { type: 'exponential', delay: 1000 },
removeOnComplete: false,
removeOnFail: false,
},
);
}

This approach embodies several virtues of practical justice:

  • Clarity: Each judgment has a single, clear purpose
  • Resilience: Built-in retry mechanisms handle temporary setbacks
  • Transparency: Progress is easily tracked and understood
  • Simplicity: No complex hierarchies or state management

Lessons in Practical Architecture

The journey to Dike taught us valuable lessons about system design:

  1. Embrace Simplicity: Complex theories often overcomplicate practical solutions
  2. Trust in Foundations: Solid transaction handling and direct processing are crucial
  3. Learn from Experience: Each iteration brought us closer to practical wisdom
  4. Balance is Key: Like Dike's scales, good architecture finds equilibrium between theory and practice

The Legend of Three Divine Attempts

The Moment of Judgment

They say in ancient times, when Mercury sought to bring order to the markets of Mount Olympus, he called upon three divine beings for help.

First came Kairos, god of perfect moments and immutable truth. He proposed a system of divine snapshots - each market's state frozen in time, each comparison creating new, perfect copies of truth. But the markets of Olympus were ever-changing, and the cost of creating these perfect, immutable moments for each comparison grew too great. The divine scrolls filled with countless versions of truth, each pure but overwhelming in their number.

Then Mercury summoned Hermes, keeper of divine records. Hermes approached with a scroll that recorded not the states, but the events themselves - each comparison a story, each decision a chapter in an eternal narrative. Yet as the chronicles grew, reconstructing the present from the past became an ever-more-complex tale. The events, though perfectly preserved, wove a tapestry too intricate to unravel in the fleeting moments when decisions were needed.

Finally, Mercury sought counsel from Themis, goddess of divine law. But it was her daughter Dike who stepped forward, having learned from her mother that while divine law provides structure, justice must be practical to be effective. "The markets need neither perfect snapshots nor perfect memories," she declared, "but fair judgment in the present moment." She took her scales and showed that simple, direct comparisons, each weighed carefully in its own time, would bring the order they sought.

And so it was that Dike's method prevailed where others had faltered. Not through immutable purity like Kairos, nor through perfect event histories like Hermes, but through the wisdom of practical justice - handling each comparison directly, with neither the burden of immutability nor the complexity of event sourcing.

The markets of Olympus found their order at last, and Mercury learned that sometimes the wisest solution lies not in theoretical perfection, but in practical justice - we need only the courage to embrace it.