<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Data on PHP Boy Scout</title>
        <link>https://phpboyscout.uk/tags/data/</link>
        <description>Recent content in Data on PHP Boy Scout</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-gb</language>
        <copyright>Matt Cockayne</copyright>
        <lastBuildDate>Sat, 28 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://phpboyscout.uk/tags/data/index.xml" rel="self" type="application/rss+xml" /><item>
            <title>The estate list became an API</title>
            <link>https://phpboyscout.uk/the-estate-list-became-an-api/</link>
            <pubDate>Sat, 28 Nov 2026 00:00:00 +0000</pubDate>
            <guid>https://phpboyscout.uk/the-estate-list-became-an-api/</guid>
            <description>&lt;img src=&#34;https://phpboyscout.uk/the-estate-list-became-an-api/cover-the-estate-list-became-an-api_hu_c8c36205a2d6a2c.jpg&#34; alt=&#34;Featured image of post The estate list became an API&#34; /&gt;&lt;p&gt;What happens to a web page when a machine starts reading it? I found out this autumn, with the &lt;a class=&#34;link&#34; href=&#34;https://phpboyscout.uk/projects/&#34; &gt;projects page&lt;/a&gt; on this site. It started life as a list for people, well over a hundred entries, grouped and described, with a logo where I&amp;rsquo;ve drawn one and a link to each microsite, and if an entry was a bit out of date, the worst that happened was a reader seeing a slightly stale description.&lt;/p&gt;&#xA;&lt;p&gt;Then a CI job started reading it, and the stakes went up rather a lot.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-question-that-started-it&#34;&gt;The question that started it&#xA;&lt;/h2&gt;&lt;p&gt;The job was cicd&amp;rsquo;s &lt;a class=&#34;link&#34; href=&#34;https://phpboyscout.uk/the-core-goes-first/&#34; &gt;core-currency guard&lt;/a&gt;, which checks that a module releasing as part of a Go family requires its core&amp;rsquo;s latest version. It needed to know which modules are cores, and that lived in a private file in my org project, which a pipeline could only read with a token and an allowlist.&lt;/p&gt;&#xA;&lt;p&gt;So I wondered about the obvious thing first: was there any value in publishing that file somewhere public, readable without a git client? And then, thinking about it a bit longer, the better question. The blog already had a data structure for the projects in the estate, with rough families and logical groupings. Why publish a second list when the first one could be made trustworthy instead?&lt;/p&gt;&#xA;&lt;p&gt;So now there&amp;rsquo;s one source, a data file in the blog, and everything renders from it: the projects page, the site search, &lt;code&gt;llms.txt&lt;/code&gt;, the count on the homepage, and two feeds, &lt;a class=&#34;link&#34; href=&#34;https://phpboyscout.uk/projects.json&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;&lt;code&gt;/projects.json&lt;/code&gt;&lt;/a&gt; and &lt;code&gt;/projects.yaml&lt;/code&gt;, for anything that wants to read the estate mechanically.&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-chalkboard-the-till-reads&#34;&gt;A chalkboard the till reads&#xA;&lt;/h2&gt;&lt;p&gt;What changes when a machine reads your list is the cost of a mistake, and the easiest way I&amp;rsquo;ve found to see it is down the pub.&lt;/p&gt;&#xA;&lt;p&gt;Picture the specials board in a pub. The landlord chalks it up each morning, and if they get the price of the pie wrong, a customer raises an eyebrow and the barman sorts it out. Now wire the board to the till, so the till charges whatever&amp;rsquo;s chalked up, and the same smudge becomes a wrong bill for every customer who orders the pie, with no barman in the loop to catch it.&lt;/p&gt;&#xA;&lt;p&gt;The projects page was the board and the feed is the till, so the design comes down to one decision: when the data is ambiguous, refuse to build instead of guessing.&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-repository-or-a-product&#34;&gt;A repository or a product&#xA;&lt;/h2&gt;&lt;p&gt;The first ambiguity was what an entry even &lt;em&gt;is&lt;/em&gt;. Some of the estate&amp;rsquo;s products are public while their code is private. Scout is the obvious one, along with a couple of family sites, and they belong on the page and in the feed, for the plain marketing reason that people should be able to find them. What mustn&amp;rsquo;t leak is anything about their repositories.&lt;/p&gt;&#xA;&lt;p&gt;So there are two kinds of entry, and the data file says so in its header. A repository entry has a path and a visibility, both required, and only a public repository&amp;rsquo;s details ever reach a feed. A product entry has no path at all: just a name, a description and its site. There&amp;rsquo;s no field on a product for a repository to leak through, because a product doesn&amp;rsquo;t have one.&lt;/p&gt;&#xA;&lt;p&gt;The templates enforce it instead of trusting it. Get the visibility wrong, or leave it off, and the site refuses to build:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-go-html-template&#34; data-lang=&#34;go-html-template&#34;&gt;{{- if not (in (slice &amp;#34;public&amp;#34; &amp;#34;private&amp;#34;) $e.repo_visibility) -}}&#xA;  {{- errorf &amp;#34;projects: %s needs repo_visibility: public or private, got %q&amp;#34; . ($e.repo_visibility | default &amp;#34;&amp;#34;) -}}&#xA;{{- end -}}&#xA;{{- if eq $e.repo_visibility &amp;#34;public&amp;#34; }}{{ $e = merge $e (dict &amp;#34;repo&amp;#34; (printf &amp;#34;https://gitlab.com/%s&amp;#34; .)) }}{{ end -}}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The link to a repository is derived from its path only when it&amp;rsquo;s public, so I can&amp;rsquo;t type a private repo&amp;rsquo;s URL into an entry by accident.&lt;/p&gt;&#xA;&lt;p&gt;On top of that sits a short list of repositories that must never appear anywhere on this site, whatever any entry says, and a check that scans both the source and the built site for them before every deploy. It refuses to pass if the list is ever empty, on the grounds that an empty deny list is far more likely to be a mistake than a triumph.&lt;/p&gt;&#xA;&lt;h2 id=&#34;checking-the-board-against-the-kitchen&#34;&gt;Checking the board against the kitchen&#xA;&lt;/h2&gt;&lt;p&gt;The list also has to stay true as the estate moves, so a script compares it with the forge itself, reading GitLab anonymously so that &amp;ldquo;public&amp;rdquo; means what a stranger can see, no more.&lt;/p&gt;&#xA;&lt;p&gt;It runs in two modes, because its findings are two kinds of problem. Before each deploy, it fails only on the mistakes that publish something wrong: an entry claiming a repository is public when a stranger can&amp;rsquo;t read it, or an entry for something archived or deleted. Every night, after the deploy, it also checks family edges against each module&amp;rsquo;s &lt;code&gt;go.mod&lt;/code&gt;, and reports anything that looks deliberate, like a public repository with no entry. A broken family edge shouldn&amp;rsquo;t hold back a scheduled post, so that one only bites at night.&lt;/p&gt;&#xA;&lt;p&gt;Who writes the entries mattered to me as well. The tempting move was a nightly job that adds anything new it finds on the forge, and I ruled it out: I&amp;rsquo;d rather have no entry than an incomplete one written by a bot, and sometimes a repository goes public before I&amp;rsquo;ve worked out where it belongs on the list. Entries are written by the session that creates a repository, or by me.&lt;/p&gt;&#xA;&lt;h2 id=&#34;where-it-bit&#34;&gt;Where it bit&#xA;&lt;/h2&gt;&lt;p&gt;Hugo bit first. Its YAML encoder, given the same empty list in several places, very helpfully anchored them&amp;hellip; and produced a file that was no longer valid YAML! The feed leaves empty lists out now, which makes for a smaller file anyway.&lt;/p&gt;&#xA;&lt;p&gt;The rename bit second, and harder. When the &lt;code&gt;go/chat-platform&lt;/code&gt; family was renamed to &lt;code&gt;go/comms&lt;/code&gt;, the old paths vanished from the forge&amp;rsquo;s public listing, and the deploy check did what I&amp;rsquo;d asked of it and found entries claiming public repositories a stranger couldn&amp;rsquo;t see. It looked like a leak, so it blocked the deploy. It wasn&amp;rsquo;t one (GitLab redirects a renamed project), so the check now asks once, and a repository that answers with a redirect to a public project gets reported as a stale entry to update, which is a job for the nightly run and no reason to stop publishing.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-number-on-the-homepage&#34;&gt;The number on the homepage&#xA;&lt;/h2&gt;&lt;p&gt;One last decision, and a small one. When everything moved onto the single source, the counts shifted. The projects page showed one number, the homepage another, smaller one, and I went to find out why. The smaller one counts only entries with a public repository, so it leaves out the products built on private code.&lt;/p&gt;&#xA;&lt;p&gt;I kept the smaller number, since it advertises the open source, the part of the estate anyone can pick up and use.&lt;/p&gt;&#xA;&lt;p&gt;These days I chalk the pie up a good deal more carefully, knowing the till&amp;rsquo;s reading over my shoulder.&lt;/p&gt;</description>
        </item></channel>
</rss>
