ADR: Docs and testing
- Status
- accepted
- Date
- 2026-09-01
A full review of the ADR set and the test
suites is planned future work; this record captures the decisions as they
stand so nothing is lost before that review happens.
In plain words
This page records how the project is documented and tested. The documents are served from the running site's menus, so a reader never has to open the code, and every release must first pass the three test suites, including a browser test for every menu of documents.
What that is worth: a developer finds each decision in one place and knows a green run means the same thing on a laptop as in a deploy, and the organization can check the site's claims against a picture or a test.
Context
The project doubles as a portfolio piece. The decisions about how it is
documented and tested accumulated across the first week of building, in
chat and in session logs, and only some of them had made it into decision
records. This ADR closes that gap.
The documentation decisions
- Docs are served by the running app, from header menus, so everything is
exposed without opening the repository. The site tells its whole story
standalone.
- The audience is a busy reviewer or a person trying to learn. Plain
language comes before jargon every time.
- Menus are organized parent over children. About holds the project docs
and the resume. Hosting holds the hosting overview with its ADRs and the
Bicep file. CI/CD holds the pipeline story. Best Practices holds the
practice record with its ADRs. A new decision gets a record and a menu
home the day it lands.
- Real configuration screenshots are embedded in the docs, captured from
the actual dashboards, so every claim can be checked against a picture.
- The production design stays documented and undeployed: main.bicep is
served in the Hosting menu as how this would be hosted in production.
The testing decisions
- Three suites gate every ship: the .NET API tests, the vitest unit tests,
and the Playwright end-to-end checks. A red suite stops the pipeline
before any image is built.
- Every doc menu gets a Playwright spec proving the menu opens its
documents in the running app. Docs are features here and get tested like
features.
- The suites run locally through the same scripts that ship, so a green
run means the same thing on a workstation and in a deploy.
Consequences
- Decisions stop living only in chat transcripts and session logs.
- The planned review has a single starting point: this record plus the
five ADRs before it.
- The cost is accepted and known: every new surface carries a doc, a menu
entry, and a spec, which slows a ship by minutes and is worth it.
Addendum, 2026-09-09: the drawing carries the two sites
The infrastructure drawing was redrawn by hand again for the morning's
change (ADR: A permanent address for the second site): the visitor's box
names both sites, the DNS box carries both CNAME records, the edge box says
the Host header picks the origin and names the two rules above the
catch-all, and the "both stores" box says the second group answers behind
the same edge at its own name and that the Store bar links each site to the
other rather than setting a cookie. A fourth drawing, TheYard's two sites,
shows that path on its own at /api/docs/diagrams/two-sites, drawn by
docs/images/two-sites.mjs in the same style. The PNG beside each SVG is
rendered by docs/images/render.mjs in the repository's own Chrome, as
before.
Addendum, 2026-09-09: the provenance stamp, and the test that keeps it out of the source
The redrawn infrastructure source reached the developer's machine eight
kilobytes heavier than it was drawn. One of the tools that carries a file
from the assistant's workspace to that machine writes a C2PA content
credential into every image it touches: a base64 manifest inside a
<metadata> element and a namespace on the root element, signed by
Anthropic and reading "Claude provided this file at the request of a user
and may have created or modified the file contents". In a photograph that is
a few kilobytes nobody sees. In this SVG it was half the file, it is not
part of the drawing, and the diagram page at
/api/docs/diagrams/infrastructure inlines the whole file into its HTML on
every visit, so every reader would have downloaded a signature block to look
at a picture.
The stamped copy was replaced before it shipped: with the two insertions
removed, the file's checksum matched the source as drawn, byte for byte, and
the PNG was re-rendered from it. DiagramPageTests now reads every SVG under
docs/images and fails on a <metadata> element or a C2PA mark, which turns
the next stamped copy into a red gate instead of a file size that looked
wrong. The mechanism, for whoever meets it next: a drawing written to the
repository by that route is read back and compared with what was sent, and
the copy that goes in is the one the repository's own shell wrote. The test,
read from this build:
[Fact]
public void Every_drawing_is_the_source_as_drawn_with_no_stamp_written_into_it()
{
string images = Path.Combine(Repo.Root(), "docs", "images");
var drawings = Directory.EnumerateFiles(images, "*.svg").OrderBy(path => path).ToList();
Assert.NotEmpty(drawings);
var stamped = drawings
.Where(path =>
{
string source = File.ReadAllText(path);
return source.Contains("<metadata", StringComparison.Ordinal)
|| source.Contains("c2pa", StringComparison.OrdinalIgnoreCase);
})
.Select(Path.GetFileName)
.ToList();
Assert.True(
stamped.Count == 0,
$"stamped on the way in, strip and re-copy: {string.Join(", ", stamped)}");
}
[Fact]
public void Every_photograph_is_the_capture_as_taken_with_no_stamp_written_into_it()
{
string images = Path.Combine(Repo.Root(), "docs", "images");
var photographs = Directory.EnumerateFiles(images)
.Where(path => Path.GetExtension(path).ToLowerInvariant() is ".png" or ".jpg" or ".jpeg")
.OrderBy(path => path)
.ToList();
Assert.NotEmpty(photographs);
var stamped = photographs
.Where(path => CarriesAStamp(File.ReadAllBytes(path)))
.Select(Path.GetFileName)
.ToList();
Assert.True(
stamped.Count == 0,
$"stamped on the way in, strip through the repository's own shell: {string.Join(", ", stamped)}");
}
private static bool CarriesAStamp(byte[] bytes)
{
ReadOnlySpan<byte> span = bytes;
foreach (string mark in new[] { "c2pa", "jumb", "jumd", "caBX", "urn:c2pa" })
{
if (span.IndexOf(System.Text.Encoding.ASCII.GetBytes(mark)) >= 0)
{
return true;
}
}
return false;
}
[Theory]
[InlineData("....caBX....")]
[InlineData("jumb")]
[InlineData("urn:c2pa:manifest")]
public void The_stamp_scan_catches_a_file_that_carries_one(string text) =>
Assert.True(CarriesAStamp(System.Text.Encoding.ASCII.GetBytes(text)));
[Fact]
public void The_stamp_scan_passes_a_plain_png_header()
{
byte[] header =
[
0x89, (byte)'P', (byte)'N', (byte)'G', 0x0D, 0x0A, 0x1A, 0x0A,
0, 0, 0, 13, (byte)'I', (byte)'H', (byte)'D', (byte)'R',
];
Assert.False(CarriesAStamp(header));
}
Live from api/TheYard.Tests/DiagramPageTests.cs, region as-drawn, read from this build at 99df7a8.
The photographs that arrived the same way carry the same credential, in the
image's own metadata rather than in markup: at this writing, eighteen of the
screenshots under docs/images. A credential in a photograph changes nothing
on the page and says nothing false about how the file travelled, so those
stay as they are unless the author wants them gone; a re-copy through the
repository's own shell removes it.
Where it sits
This one sits outside the rings: it is a process decision about serving the records from the site and gating every ship on the test suites, so the onion and SOLID do not apply to it.
Files
Documentation:
Testing:
jobs:
style:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- uses: ./.github/actions/dotnet
- run: npm ci
- run: npm run format:check
- run: npm run lint
- run: npm run format:api:check
frontend:
needs: style
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- run: npm ci
- run: npx tsc -b
- run: npm run stack:check
- run: npm test
- run: npm run build
api:
needs: style
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: ./.github/actions/dotnet
- name: Run the .NET suites
run: |
set -o pipefail
dotnet test api --collect:"XPlat Code Coverage" --results-directory TestResults \
--filter "Store!=cosmos" \
--logger 'console;verbosity=normal' \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Exclude="[TheYard.Infrastructure.Cosmos]*,[TestProject]*" \
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByAttribute="GeneratedCodeAttribute" \
2>&1 | tee "$RUNNER_TEMP/dotnet-output.txt"
- name: Say which test failed, on the run page
if: failure()
run: |
if [ ! -f "$RUNNER_TEMP/dotnet-output.txt" ]; then
echo "::error::the .NET suites left no output to report"
exit 0
fi
# Three lines after each marker, because the marker is the label and
# the detail is underneath it: "Assert.Contains() Failure" says which
# assertion and the line below it says what was actually in the
# collection, and that second line is the one somebody needs.
grep -E -A 3 '^[[:space:]]*(Failed |Error Message:)' "$RUNNER_TEMP/dotnet-output.txt" \
| grep -v '^--$' \
| head -n 24 \
| while IFS= read -r line; do
printf '::error::%s\n' "$(printf '%s' "$line" | tr -d '\r' | cut -c1-400)"
done
# dotnet writes its totals two different ways depending on the
# logger: one 'Passed! - Failed: 0, Passed: 281 ...' line, or a
# four-line 'Test Run Failed. / Total tests: ...' block. The
# console logger this job asks for produces the second, so a
# pattern that only knew the first printed nothing at all.
grep -E '^[[:space:]]*(Passed!|Failed!|Test Run (Failed|Succeeded)\.|Total tests:|(Passed|Failed|Skipped):[[:space:]]+[0-9]+)' "$RUNNER_TEMP/dotnet-output.txt" \
| head -n 6 | while IFS= read -r line; do
printf '::error::%s\n' "$(printf '%s' "$line" | tr -d '\r' | cut -c1-400)"
done
{
echo '## The .NET suites failed'
echo
echo '```'
grep -E -A 6 '^[[:space:]]*Failed ' "$RUNNER_TEMP/dotnet-output.txt" | head -n 80
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Count what the tests cover
if: always()
run: python3 .github/coverage.py TestResults 90.0 75.0
- name: The quality ratchet
if: always()
run: python3 .github/quality.py . --ratchet .github/quality-ratchet.json
functions:
needs: style
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: ./.github/actions/dotnet
- name: Run the job hunt Function's tests
run: dotnet restore functions/jobhunt && dotnet test functions/jobhunt.Tests --logger 'console;verbosity=normal'
server:
needs: style
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: ./.github/actions/dotnet
- name: Run the machine lanes' tests
run: dotnet test server/JobHunt.Server.Tests --logger 'console;verbosity=normal'
database:
needs: style
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: ./.github/actions/dotnet
- run: dotnet build api/TheYard.Database/TheYard.Database.sqlproj -c Debug
- name: The build has to have produced a package
run: test -f api/TheYard.Database/bin/Debug/TheYard.Database.dacpac
- run: dotnet build functions/JobHunt.Database/JobHunt.Database.sqlproj -c Debug
- name: The campaign's build has to have produced a package
run: test -f functions/JobHunt.Database/bin/Debug/JobHunt.Database.dacpac
e2e:
needs: style
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
with:
ref: ${{ inputs.sha || github.sha }}
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- uses: ./.github/actions/dotnet
- run: npm ci
- run: npx playwright install --with-deps chrome || { test -x /opt/google/chrome/chrome && echo "::warning::the Chrome install could not fetch its system packages; the runner's own Chrome runs the suite"; }
- name: Run the browser suite
run: |
set -o pipefail
npx playwright test 2>&1 | tee "$RUNNER_TEMP/playwright-output.txt"
- name: Say what failed, on the run page
if: failure()
run: |
# Two places, because they are readable by different people.
#
# The step summary is the nice one and it renders only for somebody
# signed in. Annotations are the ones that survive: they come back
# from the public API and show at the top of the run page, which is
# what a person with no login to this repository can actually read.
# The first attempt at this wrote only a summary and taught us that.
if [ ! -f "$RUNNER_TEMP/playwright-output.txt" ]; then
echo "::error::the browser suite left no output to report"
exit 0
fi
# '[Tt]imeout of' rather than 'Timeout of': a test that runs out
# of time says 'Test timeout of 90000ms exceeded.', which the
# capital-only spelling missed, and that line is the whole
# finding when the failure is a hang.
grep -E '^[[:space:]]+[0-9]+\) |Error: |[Tt]imeout of |Timeout: |Locator: |Expected: |Received' "$RUNNER_TEMP/playwright-output.txt" \
| head -n 20 \
| while IFS= read -r line; do
# One annotation per line, trimmed: a control character or a
# newline inside one silently truncates the whole annotation.
printf '::error::%s\n' "$(printf '%s' "$line" | tr -d '\r' | cut -c1-400)"
done
tail -n 4 "$RUNNER_TEMP/playwright-output.txt" | while IFS= read -r line; do
printf '::error::%s\n' "$(printf '%s' "$line" | tr -d '\r' | cut -c1-400)"
done
{
echo '## The browser suite failed'
echo
echo '```'
tail -n 150 "$RUNNER_TEMP/playwright-output.txt"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v7
if: failure()
with:
name: playwright-report
path: playwright-report/
Live from .github/workflows/ci.yml, region ci-jobs, read from this build at 99df7a8.
The evening of the second build day, Steve asked for a diagram of the
infrastructure, as many screenshots and code references as possible, and
ruled that code shown in a record counts as commented. Three rules follow
from it, all in force.
- The infrastructure has a picture.
docs/images/infrastructure.svg
is drawn by hand from the records and the pipeline logs, rendered to
docs/images/infrastructure.png, and served at the top of the
Hosting page and the README. It is redrawn when a box changes; a picture
that disagrees with the records is a bug in the picture.
- Every surface has a screenshot from the live site. The records that
decided a look carry a capture of that look from the domain, taken by the
same headless Chrome the end-to-end suite uses, signed out, so the picture
is what a visitor sees and not what a developer sees. The captures live in
docs/images beside the configuration screenshots from the first
day. The first pass found a real defect: a long Azure event message ran
past the edge of its card, fixed in the same version.
- Code shown in a record is documented by the record, and teaches. A
region marker names its record in a comment, the record explains the code
beside the live sample, and the region itself opens with a comment written
for someone meeting the pattern for the first time: why it is done this
way, and what breaks otherwise. Steve's rule for it, on the second build
day: "any code samples must be well documented, that helps people learn
and grow." Code no record shows keeps the comments a reader needs at the
line. Code that no record shows keeps its own comments. So the
question for a reviewer is never "is this commented" but "which record
shows this", and the Files section at the end of every record answers it.
- A diagram opens on its own page. The picture in a record is a preview
that links to the drawing on a page of its own, opened in a new tab,
zoomable, with its text selectable; the Data Flow page's text diagram
became a drawing in the same style as the infrastructure one. Recorded in
ADR: Diagram pages.
The unit suite's configuration and the end-to-end suite's two servers, read
from this build (vite.config.ts, playwright.config.ts):
test: {
include: ['src/**/*.test.ts', 'render/**/*.test.ts', 'tests/budgets/*.test.ts'],
coverage: {
provider: 'v8',
include: ['src/lib/blog*.ts', 'render/security.ts', 'render/page.ts'],
exclude: ['**/*.test.ts'],
reporter: ['text-summary'],
thresholds: { lines: 99, statements: 97, functions: 98, branches: 91 },
},
css: {
include: [
/(colors|sizes|typography|effects)\.css\?raw$/,
/panels\.css\?raw$/,
/Ribbons\.module\.css\?raw$/,
/(components|library)\/.+\.module\.css\?raw$/,
],
},
},
Live from vite.config.ts, region unit-tests, read from this build at 99df7a8.
webServer: [
{
command: process.env.YARD_API_PREBUILT
? 'dotnet run --no-build --project api/TheYard.Api'
: 'npm run api',
env: {
Market__GraceSeconds: '0',
Admin__Key: 'e2e-admin-key',
Admin__VisitorRows: 'true',
Logs__DrainSeconds: '2',
Foreman__Mode: 'recorded',
},
url: 'http://localhost:5210/api/facets',
reuseExistingServer: true,
timeout: 120_000,
},
{
command: process.env.YARD_WEB_PREVIEW
? 'npx vite preview --port 5173 --strictPort'
: 'npm run dev',
url: 'http://localhost:5173',
reuseExistingServer: true,
timeout: 120_000,
},
...(process.env.YARD_RENDER
? [
{
command: 'node render/server.mjs',
env: {
PORT: '5220',
YARD_SITES: 'sql=http://localhost:5173',
YARD_PASS_ORIGIN: 'http://localhost:5173',
YARD_DEADLINE_MS: '20000',
},
url: 'http://localhost:5220/readyz',
reuseExistingServer: true,
timeout: 120_000,
},
]
: []),
],
Live from playwright.config.ts, region web-servers, read from this build at 99df7a8.
The one record of every document the sidebar can open
(src/library/documents.ts, reading src/library/records.ts and src/library/pages.ts):
export const DOCS: Record<DocKey, DocEntry> = { ...RECORDS, ...PAGES };
Live from src/library/documents.ts, region docs-record, read from this build at 99df7a8.
Addendum, 2026-09-09: the picture redrawn for two stores
The infrastructure drawing gained a row: the Azure Cosmos DB store beside the
Azure SQL one, and a box for both stores in one process with the toggle, the
peer read and the proof (ADR: One container, both stores; ADR: Same
performance, proven). The ship lane's arrows up to the origin now route
between the two store boxes, the counts in the CI box were brought up to the
suites as they run today, and the date in the heading moved. The preview is
rendered from the SVG at twice its size by
docs/images/render.mjs,
in the repository's own Chrome with the site's font, so the picture on the
README is the drawing and not a second drawing of it.
Addendum, 2026-09-13: the photographs stripped too, and the test widened to them
The first addendum left the eighteen PNG and JPEG screenshots that had
arrived by the same route with their credential in place, on the argument
that a credential in a photograph changes nothing on the page. The owner's
answer, on 9 September, was that a signed machine-provenance credential on
his images is exactly the signal he asked to have removed, and the argument
does not survive that: the rule is about what the repository carries, not
about what a reader can see.
Measured before the strip, every raster image under docs/images read for
the marks: 64 images, 18 carrying c2pa, jumb, jumd and urn:c2pa, the
four cosmos-*.png from 8 September and fourteen captures from 9 September
(the netlify-*.jpg, timing-*.png, toggle-site-*.png and
wix-dns-two-sites.jpg files). In a PNG the manifest is a JUMBF box inside a
caBX chunk; in a JPEG it is a JUMBF box carried across APP11 segments.
Both are ancillary: the pixels are in the IDAT chunks and the entropy-coded
scan, and neither is touched by removing the box.
The strip ran through the repository's own shell rather than through the
tool that stamps, one script over all eighteen: the caBX chunks dropped
from the PNGs, the APP11 segments dropped from the JPEGs, and every file
verified afterwards on two counts, that no mark remains and that the image
data is byte for byte what it was, the IDAT chunks concatenated for a PNG
and everything outside the removed segments for a JPEG. A copy as drawn does
not exist for a screenshot the way it does for a drawing, so identical image
data is the proof that stands in for the checksum.
DiagramPageTests now reads every PNG and JPEG under docs/images for the
same marks the SVG check reads for, and the scan is proven able to fail on
a file that carries one. The test, read from this build:
[Fact]
public void Every_drawing_is_the_source_as_drawn_with_no_stamp_written_into_it()
{
string images = Path.Combine(Repo.Root(), "docs", "images");
var drawings = Directory.EnumerateFiles(images, "*.svg").OrderBy(path => path).ToList();
Assert.NotEmpty(drawings);
var stamped = drawings
.Where(path =>
{
string source = File.ReadAllText(path);
return source.Contains("<metadata", StringComparison.Ordinal)
|| source.Contains("c2pa", StringComparison.OrdinalIgnoreCase);
})
.Select(Path.GetFileName)
.ToList();
Assert.True(
stamped.Count == 0,
$"stamped on the way in, strip and re-copy: {string.Join(", ", stamped)}");
}
[Fact]
public void Every_photograph_is_the_capture_as_taken_with_no_stamp_written_into_it()
{
string images = Path.Combine(Repo.Root(), "docs", "images");
var photographs = Directory.EnumerateFiles(images)
.Where(path => Path.GetExtension(path).ToLowerInvariant() is ".png" or ".jpg" or ".jpeg")
.OrderBy(path => path)
.ToList();
Assert.NotEmpty(photographs);
var stamped = photographs
.Where(path => CarriesAStamp(File.ReadAllBytes(path)))
.Select(Path.GetFileName)
.ToList();
Assert.True(
stamped.Count == 0,
$"stamped on the way in, strip through the repository's own shell: {string.Join(", ", stamped)}");
}
private static bool CarriesAStamp(byte[] bytes)
{
ReadOnlySpan<byte> span = bytes;
foreach (string mark in new[] { "c2pa", "jumb", "jumd", "caBX", "urn:c2pa" })
{
if (span.IndexOf(System.Text.Encoding.ASCII.GetBytes(mark)) >= 0)
{
return true;
}
}
return false;
}
[Theory]
[InlineData("....caBX....")]
[InlineData("jumb")]
[InlineData("urn:c2pa:manifest")]
public void The_stamp_scan_catches_a_file_that_carries_one(string text) =>
Assert.True(CarriesAStamp(System.Text.Encoding.ASCII.GetBytes(text)));
[Fact]
public void The_stamp_scan_passes_a_plain_png_header()
{
byte[] header =
[
0x89, (byte)'P', (byte)'N', (byte)'G', 0x0D, 0x0A, 0x1A, 0x0A,
0, 0, 0, 13, (byte)'I', (byte)'H', (byte)'D', (byte)'R',
];
Assert.False(CarriesAStamp(header));
}
Live from api/TheYard.Tests/DiagramPageTests.cs, region as-drawn, read from this build at 99df7a8.
The rule, stated once for every image type: a file that crossed from the
assistant's workspace is read back before it is committed, and the copy that
goes in is the one the repository's own shell wrote.
Enforced by
3 rules in the rulebook cite this record, each held by a test on every release.