Skip to content

ADR: One reading for the first screen

ADR: One reading for the first screen

Status
accepted
Date
2026-10-17

The landing page reads /api/pulse, one small public object built from the sources the Admin tab already reads, kept for fifteen seconds and read again every fifteen while the page is open and visible. Every figure in it is nullable, and a null means unread rather than zero.

In plain words

The first screen now shows what the site is doing while you look at it: how long it takes to answer, what it has cost Azure this month, and how long it has been up since the last deploy. Those numbers come from one small request rather than from the two heaviest reads on the site, so a page anyone can open does not cost what the operator's own tab costs.

What that is worth: a stranger sees a running system rather than a description of one, and the page that proves it stays cheap enough to leave open.

Context

The three figures already existed. How fast the site answers is folded into the kept machine minutes every minute (ADR: What the machines are doing). What Azure charges is read once an hour and kept (ADR: What Azure charges). The uptime and the build are on the health report and the version route.

Reading them the way the Admin tab reads them would have put /api/admin/machines and /api/admin/costs on the landing page. Those two are the slowest reads on the site: the machines read queries the document store for a day of buckets, and the cost read walks the kept days. The landing page is the one page a stranger opens, often on a phone, and it is also the page the rendering service draws ahead of time.

Decision

One route, public, and small. GET /api/pulse answers ten fields and nothing else. It is public because the readings it carries are already public: the cost cards are public on the owner's own ruling, and the machines card is public beside them. It carries no visitor, no address and nothing per person.

// Public, like the readings it carries: the cost cards and the machines card are already
// public on the Admin tab by the owner's own ruling (ADR: What Azure charges). One read
// rather than those two, because the landing page is what a stranger opens and the two
// Admin reads behind these figures are the heaviest on the site. The answer is kept for
// fifteen seconds, so a page open on a desk costs four reads a minute however many people
// are looking at it.
app.MapGet("/api/pulse", Read)
    .WithName("GetPulse")
    .WithTags("Health")
    .WithSummary("How fast the site is answering, what it costs this month, and how long it has been up")
    .WithDescription("The first screen's one reading, built from the same sources as the Admin tab's machines and cost cards and kept for fifteen seconds. Every figure is nullable; a null means unread, never zero.")
    .Produces<PulseReply>(StatusCodes.Status200OK);

Live from api/TheYard.Api/Features/Health/PulseEndpoints.cs, region pulse-route, read from this build at 99df7a8.

Fifteen seconds, held once. The answer is built at most once every fifteen seconds and handed to every caller in that window, under one gate, so a burst of arrivals costs one query rather than one each. Fifteen because the page reads again at the same interval: a reader watching the band sees it change within a quarter of a minute of the site changing, and a page left open all day costs four reads a minute whoever is looking at it. The page stops reading while the tab is hidden, so a phone in a pocket costs nothing.

/// <summary>
/// The one light read behind the first screen (ADR: One reading for the first screen).
///
/// <para>The figures it carries already exist, on two of the Admin tab's heaviest reads: the kept
/// machine minutes and the hourly cost read. The landing page is the page a stranger opens, so it
/// cannot call either of those on every visit. This asks the same sources, keeps the answer for
/// fifteen seconds, and hands every visitor in that window the same object. The day of machine
/// minutes is read whole only now and then, and its short tail the rest of the time (PulseDay).</para>
///
/// <para>One read at a time: the gate is held while the first caller builds the answer, so a burst
/// of arrivals costs one query rather than one each.</para>
/// </summary>
public sealed class PulseReader(
    IMachineHistory history,
    string site,
    CostHistoryReader costs,
    HostStart start,
    BuildInfo build,
    TimeProvider clock,
    Func<CancellationToken, Task<PeopleCount>>? people = null)
{
    /// <summary>How long an answer is handed out before it is built again.</summary>
    public static readonly TimeSpan Every = TimeSpan.FromSeconds(15);

    /// <summary>The day the latency figure covers.</summary>
    public static readonly TimeSpan Day = TimeSpan.FromHours(24);

    private readonly SemaphoreSlim _gate = new(1, 1);
    // Made on the first read rather than in an initializer, so the history is captured once, not twice.
    private PulseDay? _day;
    private PulseReply? _last;
    // Ticks rather than a DateTimeOffset: a reader outside the gate reads this in one word, so it
    // never sees half of one instant and half of another.
    private long _builtAtTicks;

    /// <summary>Whether the answer in hand is still inside its fifteen seconds.</summary>
    private bool Fresh(DateTimeOffset now) =>
        now - new DateTimeOffset(Volatile.Read(ref _builtAtTicks), TimeSpan.Zero) < Every;

    /// <summary>The pulse, built at most once every <see cref="Every"/>.</summary>
    public async Task<PulseReply> ReadAsync(CancellationToken cancellation)
    {
        var now = clock.GetUtcNow();
        if (_last is { } kept && Fresh(now))
        {
            return kept;
        }

        await _gate.WaitAsync(cancellation);
        try
        {
            now = clock.GetUtcNow();
            if (_last is { } again && Fresh(now))
            {
                return again;
            }

            _last = await BuildAsync(now, cancellation);
            Volatile.Write(ref _builtAtTicks, now.UtcTicks);
            return _last;
        }
        finally
        {
            _gate.Release();
        }
    }

    private async Task<PulseReply> BuildAsync(DateTimeOffset now, CancellationToken cancellation)
    {
        IReadOnlyList<MachineBucket> buckets = [];
        if ((await history.AvailabilityAsync(cancellation)).Available)
        {
            _day ??= new PulseDay(history, site);
            buckets = await _day.ReadAsync(now, cancellation);
        }

        // The month window is what the cost card calls 30d, which is the one that carries the
        // month to date and the forecast.
        var bill = await costs.ReadAsync("30d", cancellation);
        int requests = buckets.Sum(bucket => bucket.Requests);
        // The people who have visited, read through the Admin tab's own query (ADR-116), so the first screen
        // and the Activity card can never say two numbers. A count that cannot be read is unread on the band,
        // never a first screen that fails: the store behind it is one the page did not depend on before.
        PeopleCount? count = null;
        if (people is not null)
        {
            try
            {
                count = await people(cancellation);
            }
            catch (Exception ex) when (ex is not OperationCanceledException and not OutOfMemoryException)
            {
                count = null;
            }
        }
        return new PulseReply(
            UsualP95(buckets),
            buckets.Count == 0 ? null : requests,
            bill.Available ? bill.MonthToDate : null,
            bill.Available ? bill.ForecastMonth : null,
            bill.Currency,
            bill.ReadAtMs,
            (long)(now - start.At).TotalSeconds,
            build.Version,
            build.Commit,
            now.ToUnixTimeMilliseconds(),
            count?.PeopleAllTime,
            count is { PeopleAllTime: not null } ? [.. count.PeopleNewByDay.Select(day => day.People)] : null,
            count?.CountedFrom,
            count?.Visits?.AllTime,
            count?.Visits?.From,
            count?.Visits is { } kept ? [.. kept.ByDay.Select(day => day.Visits)] : null);
    }

    /// <summary>
    /// The usual five minutes at the ninety-fifth percentile, over the buckets given, weighted by
    /// how many requests each bucket answered; null when no bucket answered one.
    ///
    /// <para>What it is not: the ninety-fifth percentile of the day. That would need every request's
    /// duration for a day, and what is kept is each five minutes already folded to its own counts
    /// (ADR: What the machines are doing), where a bucket's figure is its worst minute's
    /// ninety-fifth. So this takes the middle five minutes of the day by request count, which
    /// answers "how long does this site usually take at its slow end" rather than "how slow was
    /// the worst of the day" - the worst is on the Admin tab, where the card has room to say so.
    /// Taking each five minutes at its worst minute makes the figure cautious rather than
    /// flattering, which is the direction a number on a public page should err in.</para>
    ///
    /// <para>Weighted by requests, so a quiet five minutes with two requests in it does not count
    /// the same as a busy one with two hundred.</para>
    /// </summary>
    public static long? UsualP95(IReadOnlyList<MachineBucket> buckets)
    {
        var measured = buckets
            .Where(bucket => bucket.Requests > 0 && bucket.P95Ms is not null)
            .OrderBy(bucket => bucket.P95Ms!.Value)
            .ToList();
        if (measured.Count == 0)
        {
            return null;
        }

        long half = measured.Sum(bucket => (long)bucket.Requests) / 2;
        long seen = 0;
        foreach (var bucket in measured)
        {
            seen += bucket.Requests;
            if (seen > half)
            {
                return (long)Math.Round(bucket.P95Ms!.Value, MidpointRounding.AwayFromZero);
            }
        }

        return (long)Math.Round(measured[^1].P95Ms!.Value, MidpointRounding.AwayFromZero);
    }
}

Live from api/TheYard.Api/Shared/Instance/Pulse.cs, region pulse-reader, read from this build at 99df7a8.

The usual five minutes, not the newest bucket, and not the day's worst. The latency figure is the request-weighted median of the five-minute ninety-fifth percentiles over the last day. The newest bucket alone would read 1 ms on a quiet minute, which is true and reads as a trick. The day's worst minute is also true and reads as a fault. What a reader wants to know is how long this site usually takes at its slow end, and that is the middle five minutes by request count.

It is not the ninety-fifth percentile of the day, and the field is not named as though it were: the durations themselves are not kept, only each five minutes already folded to its own counts, where a bucket's own figure is its worst minute's ninety-fifth. A true figure for the day cannot be computed from what is kept, so the field is usual_p95_ms_24h, the line under the instrument says what it is, and the number of requests it rests on sits beside it. Taking each five minutes at its worst minute leaves the figure cautious rather than flattering, which is the direction a number on a public page should err in.

A null is unread. Every figure is nullable and the band prints the word rather than a number when it is missing: the cost reader answers nothing on a developer's machine, and the kept minutes answer nothing on a container with no document store. A zero in either place would claim the site cost nothing or answered in no time.

What this cost

The route is forty lines of handler and a reader of about a hundred, and it duplicates no arithmetic: the buckets and the bill are the same objects the Admin tab draws. The one number it computes itself is the weighted median above, which PulseTests holds against hand-written buckets, including a day with nothing in it.

Alternatives

Read the two Admin routes from the landing page. Rejected: the two heaviest reads on the site, on the landing page, which every visitor opens first, several times a minute.

Push the figures with a stream. Rejected for the reason the auction room already polls rather than streaming: the edge in front of this site buffers streamed responses (ADR: The room bids back). A fifteen-second read is simpler and survives the edge.

Put the numbers in the sentence. That is where they were. A sentence with numbers in it goes stale the day the numbers move, and nobody edits a sentence. A reading that is read is never stale or it says so.

Where it sits

The API layer and the landing page, nothing between. PulseReader is one class in TheYard.Api that asks the two sources the Admin tab already asks and keeps the answer for fifteen seconds; the endpoint hands it out; PulseBand draws it. Nothing in Domain or Application knows the band exists, and the band knows no arithmetic: what a figure means is decided once, on the server. What would change it is a third reader of the same two sources, at which point the keeping belongs to a reader of its own rather than to this one.

Files

Addendum, 2026-10-23 (1.0.4.41): the people who have visited

The pulse carries three more fields: people_all_time, people_new_by_day (the last thirty UTC days, oldest first) and counted_from, read through the same query the Admin tab's readouts ask (ReadPeopleCountHandler), so the first screen and the Activity card say one number. They ride the pulse's fifteen-second keep, and the visitors' store reads its tally at most once a minute, so a stranger opening the page costs nothing new. Each is null until the count has read anything, and the band's fourth instrument says "counting from" that day (ADR: People who have visited, counted once).

Addendum, 2026-10-23 (1.0.4.48): the Admin tab's reads stay out of the usual answer time, and the kept visits ride the pulse

The usual five minutes at the ninety-fifth percentile read 2,230 ms on the first screen at 20:4x on 23 October, against a day of five-minute buckets whose median was a few milliseconds. The buckets that moved it were the night's: ninety to a hundred requests each, a median of 0 ms and a ninety-fifth of two to seven seconds, from an Admin tab left open overnight whose rail asks thirteen routes a tick. The reads RequestRecorder kept out of the timing ring were a list written when the Admin tab had fewer cards; the cloud cards' routes (/api/admin/plan, /api/admin/cloud/*, /api/admin/follows, /api/admin/costs), the people count and the rest added since were not on it, and the cloud cards wait seconds on Azure Monitor, Cost Management and Netlify when a window is cold. From this version every address under /api/admin/ but the self-test stays out of the ring (RequestRecorder.IsObservabilityRead), so the usual answer time is what a visitor's requests took, and the timing section still shows the one deliberate failure. AdminObservabilityTests.The_endpoints_the_admin_tab_reads_stay_out_of_its_own_numbers holds it. The figure corrects itself as the buckets of the day roll out of the window; a burst of the site's own load reads from a laptop still looks like a visitor to the container, and is left as the day it was.

The pulse also carries visits_all_time, visits_from and visits_by_day, the visits by people across the whole kept activity, read through the same query as the people count (ADR: People who have visited, counted once, the addendum of 1.0.4.48). Null until the host's first hourly count of them.

Addendum, 2026-11-12 (1.0.5.50): the hook takes the welcome card's place

What stopped being true: the landing's first screen opened with a welcome card, "Welcome to The Yard" and a sentence about the site, with this record's band of live readouts under it, which on a phone at 390 by 844 started 415 pixels down. From this version the landing opens with its hook (ADR: A hook on every page): the quality sentence as the page's heading, the Quality page's first chart drawn from the history the build carries, and a link to the Quality page. The band stays directly below it, as the owner chose on 11 November; on a phone it now starts about 610 pixels down, still on the first screen. The card's sentence, who built the site and what it is, moved to directly under the band. The band still reads /api/pulse as decided above, and the hook reads nothing, so the box above the band draws whole on the server. hooks.spec.ts holds the hook on the first screen at 390 by 844 and the band directly under it.

Addendum, 2026-11-20 (1.0.5.140): the band is the dark live panel

The band takes the sales pages' dark live panel (ADR: The sales pages set the site's look): the head "TheYard, right now" with the LIVE tag, then the four instruments as they read, each keeping its gauge, its sparkline, its line of detail and its link, four across at a desk and two by two on a phone, on the panel's dark ground with labels in the header's quiet ink, figures white, marks and links in the light gold and live dots in the green made for the dark. The read does not change: one /api/pulse, every fifteen seconds while the tab is shown, the drawn page's reading first; an instrument the server could not read still says so in words, and the band still stands at its full height from the first paint.

Enforced by

One rule in the rulebook cites this record, each held by a test on every release.

The rule What holds it In the last gate
The first screen's one reading answers every field the band draws, and its latency figure is the request-weighted middle five minutes of the day, null when the day is empty PulseTests 10 of 10 passed
Store

The Yard, home

Steven StoutStaff .NET engineerRemote

Production .NET that stays up. Built with AI, measured on every version.

Steven Stout

Hi, I'm Steve. I build the systems that make delivery boring in the best way, then coach people inside them.

  • 200+

    production releases, none took the platform down

    Conway Investment Research, 2019 to 2024. Sole engineer for the first three years on a live financial advisory platform.

    See how
  • 50%

    shorter release cycle

    Storee Construction, 2024 to 2026. Four ASP.NET applications onto one .NET 10 platform on Azure, with a four-person team I hired and mentored.

    See how

01Verified

Steven Stout

A real person, and the work is mine.

  • Identity

    Checked by LinkedIn, not by me.

    LinkedIn verified my government ID.

  • Running system

    You are looking at it.

    Version 1.0.5.273 is live. Nothing ships unless it passes the automated gates first.

That's who I am. Here's how I work.

02Strengths

Ten strengths, each with the proof beside it. The numbers match my resume and LinkedIn, and the live ones are read from this site as you look.

  • 01

    Keeps production alive

    200+ releases on a live financial platform, and none took it down. Sole engineer for the first three years.

    See the Conway work

  • 02

    Simplifies messy systems

    Four ASP.NET applications onto one .NET 10 platform on Azure, and a release cycle 50% shorter.

    See the Storee work

  • 03

    Marries dev and infrastructure

    Blue-green releases at Storee that flipped in about 5 seconds with nobody signed out, and Azure Front Door at two employers.

    See this site's cloud

  • 04

    Designs data that holds up

    White-label clients on one shared database, the isolation built into the data, and no cross-client issues.

    See the Conway work

  • 05

    Keeps AI-written code honest

    15 quality numbers that may only improve: 273 releases in a row with none worse.

    See the quality numbers

  • 06

    Resourceful

    $30,000+ cut from Azure and vendor spend at Conway. This site's Azure bill is public, resource by resource.

    See the bill

  • 07

    Builds people up

    Hired and mentored a four-person team. 13 colleagues recommend me by name.

    Read the recommendations

  • 08

    Takes ideas to production

    This site: designed, built and run solo, with 352 versions measured through one gate.

    How it was built

  • 09

    Writes clearly

    Posts on real engineering problems, in plain words.

    Read the blog

  • 10

    Owns decisions

    153 decision records, each with its tradeoff and the call I made.

    See the decision records

Built with AI. Gated so quality never slides.

Steven Stout’s showcase: a used-vehicle auction on .NET and React, built and run by one engineer, live on Azure, with its decisions written down.

No quality number has gotten worse at any release since 1.0.5.1 on 10 November: 273 releases in a row.

One engineer, an AI agent and a gate that checks 15 quality numbers on every release. 352 versions measured, with every result public, the worst days included.

82 releases in the last 7 days, each through the same gate.

Async methods with no CancellationToken, may only fall

11091.0.3.1391.0.5.2731.0.4.115, the ratchet
Every number, on the Quality page

TheYard, right nowLive

Answering in

unread

02505007501,000

server time at p95, the usual five minutes of the last day.

Azure this month

unread

the bill, by resource, read from Azure. The Admin tab shows every line.

Since the last roll

unread

 

rolled in place by the pipeline, behind one gate.

People who have visited

unread

30 days agotoday

Scanners, my own tools' and my own reads left out.

03Start here

04Where teams are heading

How I see engineering with AI, and the setup on this site that backs it.

AI-augmented teams · Architecture and ownership

AI writes more of the code. Someone still has to own what ships.

Teams are going to be heavily AI-augmented. That moves the senior job toward architecture and technical ownership: deciding what to build in pieces small enough to verify, and owning what ships.

  • Task tracking will get automated too. Judgment stays human: seeing a design fail at scale before it does.
  • On this site the AI's first design held the whole catalogue in memory. I caught it when the App Service plan hit 82 per cent and moved the work to the store.

What the AI wrote, what I decided

07Tech stack

  •    
  •    
  •    

Read from the build, never typed by hand

What TheYard runs on

What we use, where it runs, its AWS twin, the version as built, and the file that proves it.

Cloud patterns, not one vendor: every Azure piece in this stack has a named AWS twin. Mapped, not yet run on AWS.

  • .NET 1114 projects
  • React 19.3TypeScript 7.0
  • Azure9 Bicep files
  • 11GitHub Actions workflows
The whole stack, with the file that proves each line

The last release the gate stopped was 1.0.5.258 on 2 December, at its browser 1 of 2 job.

08How it is built

09How it is run

10Who and why

Next step

11What has to work, where is it today, and what does success look like?

Book 20 minutes opens an email to me with those three questions in it, and I answer with a time.

Book 20 minutes

Your email app should have opened with this message. If it did not, copy it and send it from any mailbox.

Or message me on LinkedIn