Back to the library

Checkpoint — rollback to savepoint

Variant: Rollback to savepoint

A five-step migration sets a savepoint after step 2 — a pennant that drops in on ease-out, the one element in the piece that is set rather than run — and step 4 dies 60% of the way in. What turns rust is precisely the partial work, because the error layer is a child of the fill and inherits its extent. The rollback then unwinds last-in first-out: step 4 first, step 3 after, each on ease-in-out because it is a deliberate move on screen, and each quicker than the work it undoes, since discarding is cheaper than doing. It stops dead at the pennant; steps 1 and 2 never flicker. Rust is spent on the failure alone — the rollback is the recovery, so its labels speak in the same muted voice as the running ones. Forward work stays linear, a step running being throughput rather than a response. Use it for migrations, multi-step wizards and batch jobs where a failure should cost back to the last safe point, not to zero — and where the user needs to see where that point was.

progresserrorinfrastructureloop

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Checkpoint — rollback to savepoint</title>
    <style>
      :root {
        /* Neutrals — fixed, never remixed. */
        --ivory: #faf9f5;
        --paper: #ffffff;
        --oat: #e3dacc;
        --slate: #141413;

        /* Knobs — the remix API. A knob exists iff declared here and used below. */
        --hue: 38.8;
        --lift: 0;
        --chroma: 1;
        --round: 1;
        --speed: 1;

        /* Accents — derived from the knobs with the family's offsets baked in,
           so one hue roll moves them together. Defaults reproduce the original hex. */
        --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
        --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
        --olive: oklch(
          calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
        );
        --rust: oklch(
          calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
        );

        --_track: color-mix(in srgb, var(--oat) 62%, var(--ivory));
        --_muted: color-mix(in srgb, var(--slate) 58%, transparent);

        /* Clock — 8.4s: five steps at half a second each, a failure 60% into
           step 4, a reverse unwind that stops at the savepoint, and the
           remaining three run again. */
        --cycle: 8.4s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
        --ease-accent: cubic-bezier(0.32, 0.72, 0, 1);
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        background: var(--ivory);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
        color: var(--slate);
      }

      .card {
        width: min(300px, 86vw);
        display: grid;
        gap: 10px;
        animation: life var(--t) infinite;
      }
      @keyframes life {
        0% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        2.98%,
        94.05% {
          opacity: 1;
          animation-timing-function: ease;
        }
        98.21%,
        100% {
          opacity: 0;
        }
      }

      .row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        white-space: nowrap;
      }

      .name {
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 0.01em;
        font-variant-numeric: tabular-nums;
      }

      .state {
        display: grid;
        justify-items: end;
        font-size: 11.5px;
        font-weight: 600;
      }

      .state > span {
        grid-area: 1 / 1;
        display: flex;
        align-items: center;
        gap: 5px;
        opacity: 0;
      }

      .run,
      .again {
        color: var(--_muted);
      }

      /* Rust belongs to the failure alone; the rollback is the recovery,
         so it speaks in the same muted voice as the running states. */
      .back,
      .restored {
        color: var(--_muted);
      }

      .fail {
        color: var(--rust);
      }

      .done {
        color: var(--clay-d);
      }

      .done svg {
        width: 12px;
        height: 12px;
        overflow: visible;
      }

      .done path {
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
        stroke-dasharray: 15;
        stroke-dashoffset: 15;
      }

      /* The track carries the savepoint, so it gets headroom above the steps
         for the pennant and room below for its caption. */
      .track {
        position: relative;
        padding: 10px 0 20px;
      }

      .steps {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
      }

      .step {
        position: relative;
        height: 10px;
        border-radius: calc(3px * var(--round));
        background: var(--_track);
        overflow: hidden;
      }

      .fill {
        position: absolute;
        inset: 0;
        background: var(--clay);
        transform: scaleX(0);
        transform-origin: left center;
      }

      /* The error is a child of the fill, so it inherits the fill's exact
         extent: what turns rust is precisely the partial work, and when the
         unwind takes it the rust goes with it. */
      .err {
        position: absolute;
        inset: 0;
        background: var(--rust);
        opacity: 0;
      }

      /* Centred on the gap between steps 2 and 3. */
      .flag {
        position: absolute;
        top: 2px;
        bottom: 14px;
        left: calc((100% - 16px) * 0.4 + 5.25px);
        width: 1.5px;
        background: var(--slate);
        opacity: 0;
      }

      .flag::before {
        content: '';
        position: absolute;
        top: 0;
        left: 1.5px;
        width: 7px;
        height: 6px;
        background: var(--slate);
        clip-path: polygon(0 0, 100% 50%, 0 100%);
      }

      .flag span {
        position: absolute;
        top: calc(100% + 3px);
        left: -1px;
        font-size: 11px;
        font-weight: 500;
        font-style: normal;
        color: var(--_muted);
        white-space: nowrap;
      }

      .s1 .fill {
        animation: s1 var(--t) infinite;
      }
      .s2 .fill {
        animation: s2 var(--t) infinite;
      }
      .s3 .fill {
        animation: s3 var(--t) infinite;
      }
      .s4 .fill {
        animation: s4 var(--t) infinite;
      }
      .s5 .fill {
        animation: s5 var(--t) infinite;
      }
      .err {
        animation: err var(--t) infinite;
      }
      .flag {
        animation: flag var(--t) infinite;
      }

      /* Forward work is linear — a step running is throughput, not a
         response. The unwind is a deliberate on-screen move, so it takes
         ease-in-out, runs last-in first-out, and is quicker than the work it
         undoes: discarding is cheaper than doing. */
      @keyframes s1 {
        0%,
        3.57% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        9.52%,
        100% {
          transform: scaleX(1);
        }
      }
      @keyframes s2 {
        0%,
        10.12% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        16.07%,
        100% {
          transform: scaleX(1);
        }
      }
      @keyframes s3 {
        0%,
        18.45% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        24.4%,
        38.57% {
          transform: scaleX(1);
          animation-timing-function: var(--ease-in-out);
        }
        41.9%,
        51.19% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        57.14%,
        100% {
          transform: scaleX(1);
        }
      }
      @keyframes s4 {
        0%,
        25% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        28.57%,
        35.71% {
          transform: scaleX(0.6);
          animation-timing-function: var(--ease-in-out);
        }
        38.1%,
        57.74% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        63.69%,
        100% {
          transform: scaleX(1);
        }
      }
      @keyframes s5 {
        0%,
        64.29% {
          transform: scaleX(0);
          animation-timing-function: linear;
        }
        70.24%,
        100% {
          transform: scaleX(1);
        }
      }
      @keyframes err {
        0%,
        28.57% {
          opacity: 0;
          animation-timing-function: var(--ease-out);
        }
        30%,
        38.1% {
          opacity: 1;
          animation-timing-function: steps(1, end);
        }
        38.21%,
        100% {
          opacity: 0;
        }
      }

      /* The savepoint drops in 220ms after step 2 lands, on ease-out with 3px
         of fall — the one thing in the piece that is set rather than run. */
      @keyframes flag {
        0%,
        16.67% {
          opacity: 0;
          transform: translateY(-3px);
          animation-timing-function: var(--ease-out);
        }
        19.29%,
        100% {
          opacity: 1;
          transform: none;
        }
      }

      .run {
        animation: run var(--t) infinite;
      }
      .fail {
        animation: fail var(--t) infinite;
      }
      .back {
        animation: back var(--t) infinite;
      }
      .restored {
        animation: restored var(--t) infinite;
      }
      .again {
        animation: again var(--t) infinite;
      }
      .done {
        animation: done var(--t) infinite;
      }
      .done path {
        animation: tick var(--t) infinite;
      }
      @keyframes run {
        0%,
        28.57% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        29.76%,
        100% {
          opacity: 0;
          transform: none;
        }
      }
      @keyframes fail {
        0%,
        28.81% {
          opacity: 0;
          transform: translateY(3px);
          animation-timing-function: var(--ease-out);
        }
        30.48%,
        34.52% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        35.71%,
        100% {
          opacity: 0;
          transform: none;
        }
      }
      @keyframes back {
        0%,
        35.71% {
          opacity: 0;
          transform: translateY(3px);
          animation-timing-function: var(--ease-out);
        }
        37.38%,
        42.5% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        43.69%,
        100% {
          opacity: 0;
          transform: none;
        }
      }
      @keyframes restored {
        0%,
        43.93% {
          opacity: 0;
          transform: translateY(3px);
          animation-timing-function: var(--ease-out);
        }
        45.6%,
        47.14% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        48.33%,
        100% {
          opacity: 0;
          transform: none;
        }
      }
      @keyframes again {
        0%,
        48.57% {
          opacity: 0;
          transform: translateY(3px);
          animation-timing-function: var(--ease-out);
        }
        50.24%,
        70.24% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        71.43%,
        100% {
          opacity: 0;
          transform: none;
        }
      }
      @keyframes done {
        0%,
        70.71% {
          opacity: 0;
          transform: translateY(3px);
          animation-timing-function: var(--ease-out);
        }
        72.38%,
        100% {
          opacity: 1;
          transform: none;
        }
      }
      @keyframes tick {
        0%,
        71.43% {
          stroke-dashoffset: 15;
          animation-timing-function: var(--ease-accent);
        }
        75.24%,
        100% {
          stroke-dashoffset: 0;
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The fills still advance and unwind — they are the reading — but in
           discrete steps on one clock stretched 1.6x, and each unwind is a
           cut rather than travel. The pennant and labels fade in place. */
        .card,
        .steps .fill,
        .err,
        .flag,
        .state > span {
          animation-duration: calc(var(--t) * 1.6);
        }

        .flag,
        .state > span {
          transform: none !important;
        }

        .done path {
          animation: none;
          stroke-dashoffset: 0;
        }

        .s1 .fill {
          animation-name: s1-rm;
        }
        .s2 .fill {
          animation-name: s2-rm;
        }
        .s3 .fill {
          animation-name: s3-rm;
        }
        .s4 .fill {
          animation-name: s4-rm;
        }
        .s5 .fill {
          animation-name: s5-rm;
        }

        @keyframes s1-rm {
          0%,
          3.57% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          9.52%,
          100% {
            transform: scaleX(1);
          }
        }
        @keyframes s2-rm {
          0%,
          10.12% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          16.07%,
          100% {
            transform: scaleX(1);
          }
        }
        @keyframes s3-rm {
          0%,
          18.45% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          24.4%,
          38.57% {
            transform: scaleX(1);
            animation-timing-function: steps(1, end);
          }
          41.9%,
          51.19% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          57.14%,
          100% {
            transform: scaleX(1);
          }
        }
        @keyframes s4-rm {
          0%,
          25% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          28.57%,
          35.71% {
            transform: scaleX(0.6);
            animation-timing-function: steps(1, end);
          }
          38.1%,
          57.74% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          63.69%,
          100% {
            transform: scaleX(1);
          }
        }
        @keyframes s5-rm {
          0%,
          64.29% {
            transform: scaleX(0);
            animation-timing-function: steps(4);
          }
          70.24%,
          100% {
            transform: scaleX(1);
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="card"
      role="img"
      aria-label="A five-step migration sets a savepoint after step 2, fails partway through step 4, unwinds steps 4 and 3 in reverse back to the savepoint, then retries the remaining steps and completes"
    >
      <div class="row">
        <span class="name">migrate 0041</span>
        <span class="state">
          <span class="run">Migrating</span>
          <span class="fail">Step 4 failed</span>
          <span class="back">Rolling back to savepoint</span>
          <span class="restored">Restored to savepoint</span>
          <span class="again">Retrying from savepoint</span>
          <span class="done">
            <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8.5 L6.5 12 L13 4.5" /></svg>
            Migrated
          </span>
        </span>
      </div>
      <div class="track">
        <div class="steps">
          <span class="step s1"><span class="fill"></span></span>
          <span class="step s2"><span class="fill"></span></span>
          <span class="step s3"><span class="fill"></span></span>
          <span class="step s4"
            ><span class="fill"><span class="err"></span></span
          ></span>
          <span class="step s5"><span class="fill"></span></span>
        </div>
        <i class="flag"><span>savepoint</span></i>
      </div>
    </div>
  </body>
</html>