CClockMoraine
Workflows

Coding workflows · Vector-clock causal relations

03
Built around your work

A concrete starting point

Compare vector clocks with at most 64 named counters per map, each from zero through 10^12. Treat missing entries as zero and test equal, earlier, later and concurrent events, rejecting Boolean counters or invalid keys without mutating either map.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Vector-clock causal relations

A concrete starting point
def clock_relation(a, b):
    for clock in (a, b):
        if type(clock) is not dict or len(clock) > 64:
            raise ValueError("clock.map")
        if any(type(k) is not str or not 1 <= len(k) <= 32 or type(v) is not int or not 0 <= v <= 10**12 for k, v in clock.items()):
            raise ValueError("clock.entry")
    keys = a.keys() | b.keys()
    less = any(a.get(k, 0) < b.get(k, 0) for k in keys)
    more = any(a.get(k, 0) > b.get(k, 0) for k in keys)
    return "concurrent" if less and more else "before" if less else "after" if more else "equal"

The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.

AI coding workspace

Your next change starts here.

Get the Windows app ↗