Skip to content

The handoff delivery record is per-machine state and stops travelling (#285) - #287

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/285-delivered-per-machine
Aug 1, 2026
Merged

fdaviddpt merged 1 commit into
mainfrom
fix/285-delivered-per-machine

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #285

What was wrong

remember.delivered was written to <store>/<slug>/remember.delivered — inside the subtree 50-git-backup.sh stages — so it was committed and pushed like memory. All three claims in the report reproduce; I re-derived each rather than taking them:

  • Written where reported. scripts/session-start-hook.sh:539 (pre-fix) writes fingerprint / first_delivered / deliveries beside the handoff slot.
  • Not excluded. Staging is git add -- "$SLUG/" with no exclusion, and there is no plugin-owned place to add one — see below.
  • Fingerprint is content-derived. _remember_handoff_fingerprint() is cksum < "$1", so it matches on every machine holding the same handoff. That is the mechanism: it is the one field that is globally meaningful, and it is the field that carries the harm.
  • deliveries is not the only cross-machine-wrong field. first_delivered is one machine's wall clock and deliveries is one machine's session count — two of the three fields are per-clone by construction. fingerprint is the only shareable one, so there was never a shared value the record could have held.

The result is the inversion the reporter names: the record exists so a stale handoff cannot read as fresh, and sharing it made a fresh handoff read as stale, in the direction that suppresses action.

The decision, and what the record now promises

The record is per-clone and moves to tmp/, with the locks and the cooldown markers.

  • It now promises: this clone has already injected this exact handoff into a session N times since a local timestamp.
  • It no longer promises: anything about any other machine. Delivery state does not travel. remember.md still does — it is memory, and it is backed up exactly as before.

Namespacing per host was considered and rejected. It would preserve a hedge, not data, and buys a naming scheme plus a garbage-collection question nothing in the store answers (what removes the record for a machine that no longer exists). The cost of not sharing is that a note read on your laptop arrives on your desktop as news — which is the trade #221 already made when it stopped emptying the slot on read. Over-delivery costs a re-read; under-delivery costs the work.

Where I depart from the issue's suggested fix

The suggestion was "exclude at staging (:(exclude)), then git rm --cached". Measured, that does not hold — git commit -- <pathspec> is a partial commit that takes its content from the working tree, not the index:

  • add with :(exclude) + commit -- "$SLUG/" → the commit re-adds the file, undoing the rm --cached.
  • Excluding at commit too → the staged deletion is never committed and lingers as a permanent D in the user's index.
  • .git/info/exclude + rm --cached → an exclude rule has no effect on a tracked file; the next add re-stages it.

The only clean migration is for the path to stop existing in the working tree. So session start moves an existing record to its new home — preserving this machine's history, which is still true about this machine — and the ordinary add/commit then stages the deletion like any other file. A record arriving from someone else's push is discarded, never adopted.

Migration is required, not optional. Left tracked, the file would stay permanently modified against a version nothing maintains: noise in the user's own git status, and a name a later merge --ff-only can refuse over. One rough edge, documented in the CHANGELOG: a machine that pulls the deletion before running the new version has local changes to a file the merge removes, so that one restore can refuse; the next session moves the file aside and it clears.

Second fix, in the same seam

The reporter's structural observation is correct and is worth fixing on its own. 50-git-backup.sh:414-416 deletes the per-slug .gitignore in external mode, commenting that "the root-level .gitignore covers logs/tmp exclusions" — and the plugin never creates that file. I confirmed empirically: in a store built entirely by the plugin, logs/ is committed and pushed. The git rm --cached at :424 cannot help, because add re-stages anything an ignore rule doesn't cover.

The hook now maintains /<slug>/logs/ and /<slug>/tmp/ in the store's $GIT_DIR/info/exclude. That location rather than a .gitignore, for the three conditions #261 chose the git common dir for: no user action, no edit by this hook to a tracked file inside the user's own backup repository, and nothing that can itself be committed and land on another machine. Per-clone — exactly the scope of what it excludes. This is what the delivery record's new home depends on, so it is the fix, not adjacent cleanup.

Tests

tests/test_delivery_record_per_machine_285.py — one shared bare remote, two clones, one slug: the reported topology.

  • test_first_delivery_on_second_machine_does_not_read_as_already_seen — the behaviour, not a proxy. Machine A delivers twice and backs up; machine B pulls and opens its first session; the handoff must arrive as news. The same test asserts a repeat delivery on machine A is still labelled, so the suite cannot be satisfied by deleting the feature.
  • test_backup_does_not_carry_the_delivery_record — the mechanism, and asserts remember.md is still tracked so it fails for the right reason.
  • test_a_store_that_already_committed_the_record_is_cleaned_up — migration: the legacy tracked copy is removed and the store comes to rest with a clean git status.

test_path_resolution.py::test_handoff_delivered_and_recorded_at_session_start updated for the new path, and now also asserts the record is not written where the backup would commit it.

RED (before the fix, the reported symptom verbatim):

E  AssertionError: machine B has never delivered this handoff. Being told it was
E  already delivered N times since another machine's clock is the inversion #285
E  reports: the record that exists to stop a stale note reading as fresh instead
E  makes a fresh note read as stale.
3 failed

GREEN: 3 passed, and the full suite 1270 passed, 43 skipped, coverage 94.16%.

Docs

  • CHANGELOG.md — new ### Fixed section, both entries, including the rejected alternative and the migration rough edge.
  • README.md — the data-files table (remember.delivered row removed; logs/+tmp/ marked local and never backed up), the handoff section (a new paragraph stating outright what happens across two machines and why that direction was chosen), and the git-backup section (a "What is not backed up" paragraph — this is where people read what travels).

…elling (#285)

remember.delivered sat inside the subtree the git backup stages, so it was
committed and pushed. Its fingerprint is a cksum of the handoff CONTENT, so it
matches on every machine that has that handoff — and machine B's first session
with a note it had never seen was told it had already been delivered N times
since machine A's clock. The record that exists to stop a stale handoff reading
as fresh made a fresh one read as stale, in the direction that suppresses
action. It also conflicted on every concurrent session start, unrepairably:
union emits both key sets and yields a malformed record.

The record moves to tmp/, with the locks and the cooldown markers. It now
promises only that THIS clone has delivered THIS handoff N times since a local
timestamp, and promises nothing about any other machine. The handoff itself
still travels.

Session start moves an existing record rather than resetting it, and the move
is what retires the tracked copy: an ignore rule does nothing to a tracked
file, and a `git rm --cached` whose path still exists in the working tree is
undone by the next path-limited commit. A record arriving from a pull is
discarded, never adopted.

The backup hook also gains the exclusion it always assumed existed. Its own
comment says "the root-level .gitignore covers logs/tmp exclusions"; the plugin
never creates that file, so logs/ and tmp/ were being committed too. They are
now maintained in the store's $GIT_DIR/info/exclude — per-clone, needing no
user action, editing no tracked file, and unable to reach another machine.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 166fd6c into main Aug 1, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/285-delivered-per-machine branch August 1, 2026 10:47
fdaviddpt added a commit that referenced this pull request Aug 1, 2026
… and stop the pushing that was still happening (#288) (#289)

* fix(git-backup): a store that already tracked logs/ actually stops pushing them (#288)

#287's `git rm --cached` could never untrack them: it fails outright on a
directory without `-r`, and even with `-r` the backup's `git commit -- "<slug>/"`
is a partial commit that rebuilds those paths from the working tree. Measured on
a store built by the pre-#287 hook, the upgraded hook still pushed a log line
written after the upgrade — and tmp/ is where #287 moved the delivery record, so
#285 was not fixed on those stores either.

The untracking is now its own commit, of the index rather than of a pathspec,
guarded on an otherwise-clean index and rolled back if it cannot finish. It
rewrites no history: what is already pushed stays pushed, which is the user's
call and is documented as theirs.

Co-Authored-By: Max <noreply>

* docs: disclose session logs already in a backup remote's history (#288)

Untracking stops the pushing; it removes nothing from the commits that already
carried the logs, and no later fix on this side can. README gains "Logs in a
backup you made before this version": which versions staged logs/ unconditionally,
a one-line check for your own store, and the git filter-repo purge with its price
in the same breath — every commit ID changes, so every other clone diverges and
must be replaced rather than pulled. How many stores this touches is not known
and is not estimated.

Co-Authored-By: Max <noreply>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant