# Flag fill experiment: sources and historical limits

The machine-readable inventory is [data/flags/manifest.json](../data/flags/manifest.json).
Each asset records its Commons file page, original download URL, licence, author,
attribution, licence evidence and SHA-256 of the optimised local SVG. All 231
admitted files were labelled **Public domain** by their Commons file page's
`LicenseShortName` metadata when downloaded for this experiment. Required credits
are retained even for public-domain files. This inventory concerns flags only;
the border and population datasets retain their existing licences in README.md.

The page serves every flag from `data/flags/`. It embeds the entire flag as an SVG
image in a pattern, without extracting or independently reusing its coat of arms.
SVGO removes metadata and unnecessary precision; geometry is rounded to two decimal
places. The source files and Commons metadata are cached for auditing, but are not
committed. Changes to the vector encoding do not change the original design.
Each optimised SVG is at most 250 KB; all flag SVGs together are approximately
2.2 MB. Only the flags required by the selected year load into the browser.

## Reproduction and licence policy

```sh
npm run fetch:flags       # network required; serial requests, descriptive User-Agent
npm test                 # offline: data checks + manifest/licence/SVG/regression checks
node scripts/check-flags.mjs
node scripts/flag-coverage.mjs
```

`fetch:flags` uses Commons' file-page metadata API to resolve redirects and check
each file's licence before downloading it. It admits only PD, CC0 or CC BY
(version 1.0/2.0/2.5/3.0/4.0); CC BY-SA, GFDL, other government licences and unclear
licences are rejected. Requests run one at a time, separated by at least 600 ms.
There is a 30-second request timeout. Failures appear in `manifest.gaps`; no
unlicensed substitute is generated. The default cache is `sources/flags/`, covered
by the existing `sources/` git-ignore rule. `FLAG_CACHE=/absolute/cache/path`
selects another cache; this implementation run used a temporary cache outside
the checkout to respect its allowed write paths. Remove a cached asset's JSON and
SVG before refreshing its source or changing its Commons title.

`npm test` rejects missing or extra flag files, unapproved licences, missing
source URLs or attribution, changed checksums, scripts, event handlers, embedded
images, external references and oversized SVGs. It never refreshes downloads.
The general border-data licensing audit remains a separate command because the
existing baseline includes sources outside its allowlist.

## Date rules and interpretation

[The catalogue](../scripts/flag-catalogue.mjs) defines exact polity names and
inclusive calendar-year ranges. It provides a flag for each modern polity in
the 2019 source except Oman, plus assets for small modern states without map
geometry. This is not complete coverage of the world's historical flags.
Modern designs are applied before 2019 only where a start date has been explicitly
entered; missing eras keep their original colour. The map follows its existing
31 December convention and cannot represent a flag change within a year. Borders
after 2019 still use the source's 2019 geometry, while flag rules follow the dial
through its last year, 2025. Afghanistan (2021), Syria (2025), Honduras (2022–2025)
and the French tricolour's colour variants have separate rules.

Dependencies, dominions and protectorates use their recorded administering state's
flag. Thus British India and the pre-1931 dominions show the Union Flag in 1914.
This represents imperial affiliation; it does not claim the Union Flag was every
territory's own official local flag or colonial ensign. Tooltips and the legend
state this convention. An unrecognised owner remains a fallback. Approximate
historical underlays always remain colour fallbacks, because their shapes and
dates do not establish a period-specific flag.

The 1914 spotcheck specifically uses:

- [German Empire, 1867–1918](https://commons.wikimedia.org/wiki/File:Flag_of_Germany_(1867%E2%80%931918).svg): black, white, red; includes 1871–1918.
- [Ottoman Empire, 1844–1922](https://commons.wikimedia.org/wiki/File:Flag_of_the_Ottoman_Empire_(1844%E2%80%931922).svg): white crescent and five-pointed star on red.
- [Russian tricolour](https://commons.wikimedia.org/wiki/File:Flag_of_Russia.svg): white, blue, red; restored in 1883. The 1914 canton variant was not the official national flag and is deliberately not used. Black–yellow–white is mapped for 1858–1882. The earlier tricolour is represented as the civil/state flag for 1721–1857; Russia had no single exclusive national flag then.
- [Union Flag](https://commons.wikimedia.org/wiki/File:Flag_of_the_United_Kingdom.svg): the post-1801 design for the United Kingdom and British-administered territories. The pre-1801 Union Flag is a separate asset.

RSFSR 1918–1922, USSR 1924–1935, 1936–1954 and 1980–1990, and Russia's 1991–1992
and post-1993 tricolours have separate rules. The 1991 rule follows the 31 December flag even though the border source still labels the feature “Soviet Union”. The USSR's earliest years and
1955–1979 remain gaps rather than reusing a later design. Austria-Hungary remains
a fallback: the dual monarchy did not have a single common official national
flag. The black–yellow Austrian flag is restricted to 1804–1866.

## Known omissions

The complete fallback-name lists for each requested year are in
[coverage.json](spotchecks/flags/coverage.json). The following attempted assets
were not admitted:

| Asset | Reason |
| --- | --- |
| Modern Oman | File page reports OGL-om 1.0, outside the requested allowlist. |
| Ottoman Empire 1793–1844 | Requested Commons file page unavailable; no unverified reconstruction substituted. |
| USSR 1955–1980 | Resolved file reports CC BY-SA 3.0. |
| Tuscany 1569–1737 | Requested Commons file page unavailable. |

Early maps have many fallbacks: a recorded polity does not by itself establish
an official flag, and retrospective banners or speculative reconstructions are
not treated as evidence. This is especially visible in 1500. The manifest can be
extended with independently checked files and dated rules without changing the
renderer. Contemporary source names such as “West Germany” and “North Vietnam”
are retained from the border data and mapped to the appropriate later flags;
this experiment does not correct those source labels.
