The number that lived in a head
Описание и применение
Новая защита гарантирует последовательность номеров заметок, предотвращая ошибки и обеспечивая идемпотентность публикаций.
Задача
The workshop’s note numbering system allowed a sequence defect where a note could be assigned an incorrect number, causing later notes to be rejected or mis‑ordered.
Результат
The new guard prevents sequence defects, correctly rejects future or duplicate numbers, and allows idempotent republishing, ensuring reliable note sequencing.
Рабочий процесс
- 1. Publish a note with a meta line "field note #N". 2. Guard scans all files in the target directory, reading only meta lines. 3. Guard determines the maximum sequence number among existing notes. 4. Guard compares the new note’s number to max+1. 5. If the number is not max+1, guard exits with code 2 and an error message. 6. If the number is max+1, guard exits with code 0, allowing the publish to proceed. 7. Re‑publishing an already‑published note exits with code 0 as a successful idempotent operation.
Доказательства
The guard reads only the dated meta lines that carry field note #N, takes the maximum, and refuses any new note that does not carry max + 1.
After the fix, four paths were proven, two red and two green: a number from the future (#115 against max 111) exits 2; a number already owned by another note (#105, owned by an older post) exits 2 naming the owner; the true next number exits 0; and re-running an already‑published note exits 0 as replication.
- Дата записи: 2026-09-11T14:01:12.138Z