today 2026-10-14, day 287, year 2026; books in a fresh temporary directory

CHECK 1: unit tests
  | Ran 18 tests in 0.034s
  | 
  | OK
  ok  uv run python -m unittest passes

CHECK 2: empty first run, first add, header, help
$ uv run firsts.py   [book.txt, exit 0]
  | Nothing entered.
  | A first goes in with: uv run firsts.py add <event>
  | Years already behind you go in with: uv run firsts.py backfill
  ok  three-line empty message names uv run firsts.py, exit 0
  ok  the empty run did not create the file
$ firsts   [book.txt, exit 0]
  | Nothing entered.
  | A first goes in with: firsts add <event>
  | Years already behind you go in with: firsts backfill
  ok  through the symlink the same message names firsts and not uv run
$ uv run firsts.py add first swallow   [book.txt, exit 0]
  | Entered. swallow, 14 Oct 2026, seen. Day 287.
  | /tmp/firsts-e2e-hs2lifzm/book.txt
  ok  new file: header, # Opened today, one entry dated today
  ok  entered line with day 287 (date +%j)
$ uv run firsts.py   [book.txt, exit 0]
  | /tmp/firsts-e2e-hs2lifzm/book.txt
  |           2026
  | swallow   Oct 14
  | 
  | Book opened 14 Oct 2026. 1 entry, 0 of them older than the book. This tool has changed no line.
  ok  check 3: earlier 115 bytes are a prefix of the later 115
  ok  year 2026 sits above the first character of its column
  ok  one column for the current year, one row
  ok  colophon for one entry
$ uv run firsts.py add first swallow   [touched.txt, exit 0]
  | Entered. swallow, 14 Oct 2026, seen. Day 287.
  | /tmp/firsts-e2e-hs2lifzm/touched.txt
  ok  check 3: earlier 0 bytes are a prefix of the later 115
  ok  zero-byte file gets the same two header lines and the entry
$ uv run firsts.py --help   [book.txt, exit 0]
  | usage: uv run firsts.py [-h] {add,backfill,erratum,table} ...
  | 
  | A register of first occurrences, printed one column per year.
  | Kept in $FIRSTS_FILE, or ~/firsts.txt when that is not set.
  | With no command, prints the table (uv run firsts.py table).
  | 
  | options:
  |   -h, --help            show this help message and exit
  | 
  | commands:
  |   {add,backfill,erratum,table}
  |     add                 enter the first time something happened this year
  |     backfill            paste earlier years, one YYYY-MM-DD event per line
  |     erratum             note a correction: EVENT... YEAR TEXT...
  |     table               print the table
  | 
  | The file is yours. This tool only adds to it.
  | normal is dead
  ok  check 3: earlier 115 bytes are a prefix of the later 115
  ok  uv run firsts.py --help shows usage: uv run firsts.py
  ok  help ends with the two closing lines
$ firsts --help   [book.txt, exit 0]
  | usage: firsts [-h] {add,backfill,erratum,table} ...
  | 
  | A register of first occurrences, printed one column per year.
  | Kept in $FIRSTS_FILE, or ~/firsts.txt when that is not set.
  | With no command, prints the table (firsts table).
  | 
  | options:
  |   -h, --help            show this help message and exit
  | 
  | commands:
  |   {add,backfill,erratum,table}
  |     add                 enter the first time something happened this year
  |     backfill            paste earlier years, one YYYY-MM-DD event per line
  |     erratum             note a correction: EVENT... YEAR TEXT...
  |     table               print the table
  | 
  | The file is yours. This tool only adds to it.
  | normal is dead
  ok  check 3: earlier 115 bytes are a prefix of the later 115
  ok  firsts --help shows usage: firsts
  ok  symlink help ends with the two closing lines
$ firsts --days   [book.txt, exit 2]
  ! usage: firsts [-h] {add,backfill,erratum,table} ...
  ! firsts: error: unrecognized arguments: --days
  ok  check 3: earlier 115 bytes are a prefix of the later 115
  ok  check 3: refused command left the file identical
  ok  firsts --days exits non-zero with the usage line and no table

CHECK 4: refusal
$ uv run firsts.py add swallow   [book.txt, exit 1]
  ! swallow, 2026: already entered, 14 Oct. The first is final.
  ! To note a correction: uv run firsts.py erratum swallow 2026 <text>
  ok  check 3: earlier 115 bytes are a prefix of the later 115
  ok  check 3: refused command left the file identical
  ok  repeat add refused with already entered, The first is final.
  ok  refusal names the existing date
  ok  remedy line names uv run firsts.py
$ firsts add swallow   [book.txt, exit 1]
  ! swallow, 2026: already entered, 14 Oct. The first is final.
  ! To note a correction: firsts erratum swallow 2026 <text>
  ok  check 3: earlier 115 bytes are a prefix of the later 115
  ok  check 3: refused command left the file identical
  ok  through the symlink the remedy names firsts
$ uv run firsts.py add swallow --date 2024-03-29   [book.txt, exit 0]
  | Entered. swallow, 29 Mar 2024, seen. Day 89.
  | /tmp/firsts-e2e-hs2lifzm/book.txt
  ok  check 3: earlier 115 bytes are a prefix of the later 143
  ok  a different year succeeds (29 Mar 2024 is day 89)
$ uv run firsts.py add First Swallows   [book.txt, exit 1]
  ! swallow, 2026: already entered, 14 Oct. The first is final.
  ! To note a correction: uv run firsts.py erratum swallow 2026 <text>
  ok  check 3: earlier 143 bytes are a prefix of the later 143
  ok  check 3: refused command left the file identical
  ok  First Swallows the same year is the same event and is refused
$ uv run firsts.py add frost --date 2027-04-11   [book.txt, exit 1]
  ! 11 Apr 2027 has not happened.
  ok  check 3: earlier 143 bytes are a prefix of the later 143
  ok  check 3: refused command left the file identical
  ok  a future date is refused
$ uv run firsts.py add frost --recalled   [book.txt, exit 2]
  ! A recalled entry needs --date YYYY-MM-DD.
  ok  check 3: earlier 143 bytes are a prefix of the later 143
  ok  check 3: refused command left the file identical
  ok  --recalled without --date is refused

CHECK 5: backfill
$ uv run firsts.py backfill  <<< '2025-04-02 swallow\n2024-03-29 swallow\n2025-11-02 frost\n2024-11-09 frost | I think the 9th\n'   [backfill.txt, exit 0]
  | 4 lines entered.
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  |           2024     2025
  | swallow  [Mar 29] [Apr  2]
  | frost    [Nov  9] [Nov  2]
  | 
  | [ ] recalled
  | Not yet in 2026: frost, swallow.
  | Book opened 14 Oct 2026. 4 entries, 4 of them older than the book. This tool has changed no line.
  ok  reports 4 lines entered
  ok  year 2024 sits above the first character of its column
  ok  year 2025 sits above the first character of its column
  ok  columns for 2024 and 2025 only
  ok  all four cells in square brackets
  ok  key line is [ ] recalled and nothing else
  ok  colophon: 4 entries, 4 of them older
  ok  stored as recalled, note kept
$ uv run firsts.py backfill  <<< '2025-05-01 cuckoo\nnot a date\n2025-04-02 swallow\n2025-05-03 cuckoo\n2099-01-01 frost\n'   [backfill.txt, exit 1]
  ! Line 2 is not YYYY-MM-DD event.
  ! Line 3: swallow, 2025: already entered, 2 Apr. The first is final.
  ! Line 4: cuckoo, 2025: also given on line 1.
  ! Line 5: 1 Jan 2099 has not happened.
  ! Nothing written.
  ok  check 3: earlier 229 bytes are a prefix of the later 229
  ok  check 3: refused command left the file identical
  ok  bad paste: every bad line listed by number, nothing written
$ uv run firsts.py backfill --seen  <<< '2021-04-01 cuckoo\n'   [seen.txt, exit 0]
  | 1 line entered.
  | /tmp/firsts-e2e-hs2lifzm/seen.txt
  |          2021
  | cuckoo   Apr  1
  | 
  | Not yet in 2026: cuckoo.
  | Book opened 14 Oct 2026. 1 entry, 1 of them older than the book. This tool has changed no line.
  ok  --seen stores seen
  ok  --seen prints no brackets and no recalled key

CHECK 6: comparison and errata
$ uv run firsts.py add swallow   [backfill.txt, exit 0]
  | Entered. swallow, 14 Oct 2026, seen. Day 287.
  | 2025: [2 Apr] (day 92). This entry is 195 days later.
  | 2024: [29 Mar] (day 89). This entry is 198 days later.
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  ok  check 3: earlier 229 bytes are a prefix of the later 257
  ok  entered today
  ok  one comparison line per earlier year, newest first, right difference
$ uv run firsts.py erratum swallow 2026 the date was wrong   [backfill.txt, exit 0]
  | Erratum filed against swallow, 2026. The entry stands.
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  ok  check 3: earlier 257 bytes are a prefix of the later 322
  ok  erratum filed message
$ uv run firsts.py   [backfill.txt, exit 0]
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  |           2024     2025     2026
  | swallow  [Mar 29] [Apr  2]  Oct 14 *
  | frost    [Nov  9] [Nov  2]
  | 
  | [ ] recalled   * erratum
  | * swallow 2026, filed 14 Oct: the date was wrong
  | Not yet in 2026: frost.
  | Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  ok  check 3: earlier 322 bytes are a prefix of the later 322
  ok  year 2024 sits above the first character of its column
  ok  year 2025 sits above the first character of its column
  ok  year 2026 sits above the first character of its column
  ok  cell keeps the original date and gains *
  ok  errata block shows the text with the filed date
  ok  colophon: 5 entries, 4 older; the erratum is not counted
$ uv run firsts.py erratum nothing 2026 x   [backfill.txt, exit 1]
  ! No entry for nothing, 2026.
  ok  check 3: earlier 322 bytes are a prefix of the later 322
  ok  check 3: refused command left the file identical
  ok  erratum against a missing entry is refused
$ uv run firsts.py add wood anemone --date 2025-04-20 --recalled   [backfill.txt, exit 0]
  | Entered. wood anemone, 20 Apr 2025, recalled. Day 110.
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  ok  check 3: earlier 322 bytes are a prefix of the later 359
  ok  add wood anemone --date 2025-04-20 --recalled
$ uv run firsts.py erratum wood anemone 2025 it was a wood sorrel   [backfill.txt, exit 0]
  | Erratum filed against wood anemone, 2025. The entry stands.
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  ok  check 3: earlier 359 bytes are a prefix of the later 431
  ok  erratum files against the two-word event
$ uv run firsts.py erratum swallow 2026   [backfill.txt, exit 2]
  ! Usage: uv run firsts.py erratum EVENT... YEAR TEXT...
  ok  check 3: earlier 431 bytes are a prefix of the later 431
  ok  check 3: refused command left the file identical
  ok  erratum without text gives the usage line
$ uv run firsts.py erratum frost 2025 -the 2nd, not the 1st   [backfill.txt, exit 0]
  | Erratum filed against frost, 2025. The entry stands.
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  ok  check 3: earlier 431 bytes are a prefix of the later 497
  ok  erratum text may begin with a hyphen

CHECK 7: plain text without the tool
  > # First occurrences. One line per entry. A line is never changed.
  > # Opened 2026-10-14.
  > 2025-04-02 | recalled | swallow
  > 2024-03-29 | recalled | swallow
  > 2025-11-02 | recalled | frost
  > 2024-11-09 | recalled | frost | I think the 9th
  > 2026-10-14 | seen | swallow
  > erratum | 2026 | swallow | filed 2026-10-14 | the date was wrong
  > 2025-04-20 | recalled | wood anemone
  > erratum | 2025 | wood anemone | filed 2026-10-14 | it was a wood sorrel
  > erratum | 2025 | frost | filed 2026-10-14 | -the 2nd, not the 1st
  ok  every line is an entry, an erratum or a comment
$ uv run firsts.py   [backfill.txt, exit 0]
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  |                2024     2025     2026
  | wood anemone           [Apr 20]*
  | swallow       [Mar 29] [Apr  2]  Oct 14 *
  | frost         [Nov  9] [Nov  2]*
  | 
  | [ ] recalled   * erratum
  | * wood anemone 2025, filed 14 Oct 2026: it was a wood sorrel
  | * swallow 2026, filed 14 Oct: the date was wrong
  | * frost 2025, filed 14 Oct 2026: -the 2nd, not the 1st
  | Not yet in 2026: frost, wood anemone.
  | Book opened 14 Oct 2026. 6 entries, 5 of them older than the book. This tool has changed no line.
  ! Line 12 repeats swallow 2025. The first line stands.
  ! Line 13 is not an entry. Left as it is.
  ok  check 3: earlier 560 bytes are a prefix of the later 560
  ok  the table still prints
  ok  stderr: line 12 repeats
  ok  stderr: line 13 is not an entry
  ok  colophon counts only the entries the table is built from
  ok  the read left the file byte for byte unchanged
$ uv run firsts.py   [backfill.txt, exit 0]
  | /tmp/firsts-e2e-hs2lifzm/backfill.txt
  |                2024     2025     2026
  | wood anemone           [Apr 20]*
  | swallow       [Mar 29] [Apr  2]  Oct 14 *
  | frost         [Nov  9] [Nov  2]*
  | 
  | [ ] recalled   * erratum
  | * wood anemone 2025, filed 14 Oct 2026: it was a wood sorrel
  | * swallow 2026, filed 14 Oct: the date was wrong
  | * frost 2025, filed 14 Oct 2026: -the 2nd, not the 1st
  | Not yet in 2026: frost, wood anemone.
  | 6 entries. This tool has changed no line.
  ! Line 11 repeats swallow 2025. The first line stands.
  ! Line 12 is not an entry. Left as it is.
  ok  check 3: earlier 539 bytes are a prefix of the later 539
  ok  without # Opened the colophon is N entries.

CHECK 8: table layout in a real terminal
  tmux 80x24 backfill-80:
  : $ firsts backfill
  : Paste one line per entry: YYYY-MM-DD event. End with Ctrl-D.
  : 2025-04-02 swallow
  : 2024-03-29 swallow
  : 2023-04-10 swallow | about the second week, I think
  : 2025-11-02 frost
  : 4 lines entered.
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2023     2024     2025
  : swallow  [Apr 10] [Mar 29] [Apr  2]
  : frost                      [Nov  2]
  : 
  : [ ] recalled
  : Not yet in 2026: frost, swallow.
  : Book opened 14 Oct 2026. 4 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  ok  interactive backfill prompts on a terminal and enters 4 lines
  tmux 80x24 add-80:
  : $ firsts add first swallow --note over the mill pond
  : Entered. swallow, 14 Oct 2026, seen. Day 287.
  : 2025: [2 Apr] (day 92). This entry is 195 days later.
  : 2024: [29 Mar] (day 89). This entry is 198 days later.
  : 2023: [10 Apr] (day 100). This entry is 187 days later.
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  : $ 
  ok  add with an unquoted --note
  tmux 80x24 refusal-80:
  : $ firsts add swallow
  : swallow, 2026: already entered, 14 Oct. The first is final.
  : To note a correction: firsts erratum swallow 2026 <text>
  : $ 
  tmux 80x24 erratum-80:
  : $ firsts erratum swallow 2026 the date was wrong
  : Erratum filed against swallow, 2026. The entry stands.
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  : $ 
  tmux 80x24 table-80-plain:
  : $ firsts
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2023     2024     2025     2026
  : swallow  [Apr 10] [Mar 29] [Apr  2]  Oct 14 *
  : frost                      [Nov  2]
  : 
  : [ ] recalled   * erratum
  : * swallow 2026, filed 14 Oct: the date was wrong
  : Not yet in 2026: frost.
  : Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  ok  at least four years shown: ['2023', '2024', '2025', '2026']
  ok  no header or row line exceeds 80 (widest 45)
  ok  year 2023 sits above the first character of its column
  ok  year 2024 sits above the first character of its column
  ok  year 2025 sits above the first character of its column
  ok  year 2026 sits above the first character of its column
  ok  every cell is nine characters and aligned under its year
  ok  a recalled entry is in the table
  ok  NO_COLOR=1: no escape bytes in the escaped capture
  tmux 40x24 table-40-plain:
  : $ firsts
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2024     2025     2026
  : swallow  [Mar 29] [Apr  2]  Oct 14 *
  : frost             [Nov  2]
  : 
  : Years before 2024 not shown. firsts table --from 2023.
  : [ ] recalled   * erratum
  : * swallow 2026, filed 14 Oct: the date was wrong
  : Not yet in 2026: frost.
  : Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  ok  oldest years dropped at 40: [2024, 2025, 2026]
  ok  no header or row line exceeds 40 (widest 36)
  ok  hint names --from the oldest year in the file: Years before 2024 not shown. firsts table --from 2023.
  ok  NO_COLOR=1: no escape bytes at 40 columns
  tmux 40x24 from-40-plain:
  : $ firsts table --from 2023
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2023     2024     2025     2026
  : swallow  [Apr 10] [Mar 29] [Apr  2]  Oct 14 *
  : frost                      [Nov  2]
  : 
  : [ ] recalled   * erratum
  : * swallow 2026, filed 14 Oct: the date was wrong
  : Not yet in 2026: frost.
  : Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  ok  --from prints every year
  ok  --from header and rows are wider than the terminal (45 > 40)

CHECK 9: colour is conditional
  tmux 80x24 table-80:
  : $ firsts
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2023     2024     2025     2026
  : swallow  [Apr 10] [Mar 29] [Apr  2]  Oct 14 *
  : frost                      [Nov  2]
  : 
  : [ ] recalled   * erratum
  : * swallow 2026, filed 14 Oct: the date was wrong
  : Not yet in 2026: frost.
  : Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  ok  truecolor tty: brick 24-bit colour present
  ok  row paints only brackets and *: []
  ok  row paints only brackets and *: ['[', ']', '[', ']', '[', ']', '*']
  ok  row paints only brackets and *: ['[', ']']
  ok  key paints only its marks: ['[ ]', '*']
  ok  errata block line is brick: * swallow 2026, filed 14 Oct: the date was wrong
  ok  no colour on: Not yet in 2026: frost.
  ok  no colour on: Book opened 14 Oct 2026. 5 entries, 4 of
  ok  path line and prompt carry no colour
$ uv run firsts.py table   [firsts.txt, exit 0]
  | /tmp/firsts-e2e-hs2lifzm/firsts.txt
  |           2023     2024     2025     2026
  | swallow  [Apr 10] [Mar 29] [Apr  2]  Oct 14 *
  | frost                      [Nov  2]
  | 
  | [ ] recalled   * erratum
  | * swallow 2026, filed 14 Oct: the date was wrong
  | Not yet in 2026: frost.
  | Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  ok  check 3: earlier 360 bytes are a prefix of the later 360
  ok  COLORTERM=truecolor but piped: no ANSI escapes
  tmux 40x24 table-40:
  : $ firsts
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2024     2025     2026
  : swallow  [Mar 29] [Apr  2]  Oct 14 *
  : frost             [Nov  2]
  : 
  : Years before 2024 not shown. firsts table --from 2023.
  : [ ] recalled   * erratum
  : * swallow 2026, filed 14 Oct: the date was wrong
  : Not yet in 2026: frost.
  : Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  tmux 80x24 days-80:
  : $ firsts table --days
  : /tmp/firsts-e2e-hs2lifzm/firsts.txt
  :           2023     2024     2025     2026
  : swallow  [   100] [    89] [    92]     287 *
  : frost                      [   306]
  : 
  : [ ] recalled   * erratum   Day counts from 1 Jan.
  : * swallow 2026, filed 14 Oct: the date was wrong
  : Not yet in 2026: frost.
  : Book opened 14 Oct 2026. 5 entries, 4 of them older than the book. This tool has changed no line.
  : $ 
  tmux 80x40 help-80:
  : $ firsts --help
  : usage: firsts [-h] {add,backfill,erratum,table} ...
  : 
  : A register of first occurrences, printed one column per year.
  : Kept in $FIRSTS_FILE, or ~/firsts.txt when that is not set.
  : With no command, prints the table (firsts table).
  : 
  : options:
  :   -h, --help            show this help message and exit
  : 
  : commands:
  :   {add,backfill,erratum,table}
  :     add                 enter the first time something happened this year
  :     backfill            paste earlier years, one YYYY-MM-DD event per line
  :     erratum             note a correction: EVENT... YEAR TEXT...
  :     table               print the table
  : 
  : The file is yours. This tool only adds to it.
  : normal is dead
  : $ 
  tmux 80x24 empty-80:
  : $ firsts
  : Nothing entered.
  : A first goes in with: firsts add <event>
  : Years already behind you go in with: firsts backfill
  : $ 

CHECK 3: append only, held on every command above
  ok  28 commands; 23 on an existing file kept it as a prefix; 9 refused left it identical

CHECK 10: clean
  ok  no URL in firsts.py, test_firsts.py, README.md
  ok  no em dash, en dash or emoji in ['BUILD.md', 'CARD.md', 'README.md', 'e2e.py', 'firsts.py', 'test_firsts.py']
  ok  stdlib imports only: ['argparse', 'datetime', 'os', 'pathlib', 're', 'shutil', 'string', 'sys', 'typing']
  ok  shutil is used only for ['get_terminal_size']
  ok  open( only with literal modes: ['r', 'a']
  373:        with open(path, "r", encoding="utf-8", errors="replace", newline="") as f:
391:        with open(path, "a", encoding="utf-8") as f:
  ok  none of the forbidden write calls appear in firsts.py
$ sudo -n unshare -n setpriv ... cat /proc/net/dev   interfaces: ['lo']
  ok  the namespace has only loopback
$ sudo -n unshare -n setpriv ... uv run --offline firsts.py add swallow --date 2025-04-02   [exit 0]
  | Entered. swallow, 2 Apr 2025, seen. Day 92.
  | /tmp/firsts-e2e-hs2lifzm/offline.txt
  ok  runs with the network blocked
  ok  audit hook saw no socket, urllib or http event while printing a table

ALL CHECKS PASSED
