Skip to content

Session logs already pushed to a backup remote: disclose the history, and stop the pushing that was still happening (#288) - #289

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/288-history-disclosure
Aug 1, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/288-history-disclosure

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #288

What I verified, and where it contradicts the issue

I re-derived #287's forward fix rather than taking it. Both halves are in the tree: 50-git-backup.sh:438-444 maintains /<slug>/logs/ and /<slug>/tmp/ in $GIT_DIR/info/exclude, and :450 ran git rm --cached beside them. The second half never worked. Built a store with the pre-#287 hook (git show 166fd6c^), pushed it, then ran the current hook against it:

--- tracked in HEAD after new hook:
    c--tmp-project-a/logs/pipeline-2026-08-01.log
    c--tmp-project-a/remember.md
    c--tmp-project-a/tmp/remember.delivered
--- commit 21d1129 (written by the NEW hook) CONTAINS c--tmp-project-a/logs/:
        session log line
        more log            ← written AFTER the upgrade

Two independent causes, each reproduced in isolation:

  • git rm --cached -- "$SLUG/logs/" on a directory fails outright without -r — fatal: not removing 's/logs/' recursively without -r — and the hook discards the error with 2>/dev/null || true.
  • Even with -r, the backup commits via git commit -- "$SLUG/", a partial commit, which builds its tree from the working tree for every matched path and so restores exactly what the removal staged. Micro-tested on git 2.46.2: index shows s/m.md only, HEAD after the commit shows s/logs/a.log again.

That is the same mechanism #287 documented for the delivery record and answered by making the path stop existing on disk. logs/ and tmp/ cannot take that answer — the plugin writes to them every session.

So the issue's premise is right about history and too generous about the present: it is not only that old logs sit in history, it is that new ones kept going up on exactly the affected stores. And because #287 moved the delivery record to tmp/, #285 is not fixed on a pre-#287 store either — tmp/remember.delivered was still being committed and pushed there.

One correction in the other direction, which the README now carries: the setup snippet under Back up your memory has told people to hand-write a root .gitignore with */logs/ since #60 (2026-05-24). A store set up by following the README is unaffected. That narrows who this is about without letting me claim a number, and nobody has counted — the README says so and gives the check instead.

Scope — I expanded it, and it is separable

The brief was docs-only. I could not write an honest README on top of a live leak: the true sentence would have been your logs are in history and are still being pushed. So this is two commits, and the first can be dropped without touching the second's story materially (the docs would then need one sentence changed, from "stops being pushed" to "keeps being pushed until the fix lands"):

  • 0d5b531 — the fix + tests/test_legacy_logs_untracking_288.py.
  • d9d09c5 — README + CHANGELOG disclosure.

The fix: the untracking is now its own commit, of the index rather than of a pathspec — the one commit form that can record a deletion for a path still present on disk. Guards: only when git ls-files shows something to untrack; only when git diff --cached --quiet (an index commit takes everything staged, and the store is a repo the user owns — their staged work must never land in a commit this hook wrote); git reset and a log line if it cannot finish. It rewrites nothing.

RED / GREEN

RED (fix reverted, same tests):

FAILED test_the_upgrade_untracks_logs_and_tmp
FAILED test_logs_written_after_the_upgrade_never_reach_the_remote
2 failed, 2 passed in 17.27s
E  AssertionError: logs/ is still tracked after the upgrade, so every later save
E  commits and pushes it again. tracked:
E    c--projects-legacy/logs/pipeline-2026-08-01.log
E    c--projects-legacy/remember.md
E    c--projects-legacy/tmp/last-save.json

GREEN: 4 passed in 28.93s.

The two passing tests in the RED leg are deliberate guards rather than filler: test_the_store_comes_to_rest_clean fails any fix that leaves a permanent staged D (the failure mode #287 called out), and test_history_is_left_alone fails any fix that silently rewrites the user's repository.

Full suite: 1274 passed, 43 skipped, coverage 94.16% (#287 reported 1270 / 43 / 94.16% — the +4 are these tests). Run before pushing; pushed with --no-verify for the known SIGPIPE-141 wrapper issue.

The wording, and why

New README subsection Logs in a backup you made before this version, under the git-backup section where people read what travels. Four things it does, each deliberate:

  1. Names the versions. "0.12.3 and earlier", with the escape hatch stated first — if you wrote the root .gitignore the setup snippet asks for, none of this applies to you.
  2. Separates what upgrading does from what it cannot do. "Upgrading changes what happens next and nothing about what already happened." Then, plainly: untracking a path does not rewrite the commits that hold it, and no later fix on our side can.
  3. Refuses to imply a population. "Nobody has counted how many stores are affected — this is here so you can check your own, not as an estimate of anyone else's", followed by the check. I tested the check command and fixed it: git log -- '*/logs/' returns nothing (a trailing-slash pathspec matches no blob), which would have told every affected user they were fine. It ships as '*/logs/*'.
  4. Puts the price before the command. The cost paragraph comes first and the fenced block second, so the trade cannot be skimmed past. I verified the purge end to end with git-filter-repo in a throwaway venv against a real two-clone store: history clean afterwards, memory intact, force-push accepted, and the other clone left [ahead 2, behind 2] with git pull --ff-only refusing — that is the cost, measured, and it is what the paragraph describes. Two things I would not have known to write without running it: filter-repo deletes your origin on purpose (so the recipe re-adds it), and unreachable objects can survive on the host regardless, so a rewrite is removal from the branch, not a guarantee of deletion.

It also says outright that doing nothing is a legitimate answer. These are the user's own session logs in a repository they own; the point is that it becomes a decision.

The /remember:doctor question — a recommendation, not a change

No code written for it, per the brief. My view, for what it is worth:

Do not add a permanent finding. Add a one-shot notice, or nothing. The reason is that the population changed under us. With the fix in this PR, the first backup after upgrading emits a log line naming exactly what happened, once, on the store it happened to — that is already a targeted disclosure with no ongoing cost, and it fires only for stores that actually have the condition. A doctor finding on top of that would be a second, permanent warning about a state the user has now been told about twice and may reasonably not care about, and doctor is where people go when something is wrong — a finding that can never be cleared without a history rewrite teaches them to ignore the section.

If you want more than the log line, the shape I would pick is a tmp/-markered one-shot systemMessage at the moment of untracking, in the same family as git-backup-notice — said once, to exactly the users it is true for, and never again. What I would avoid is a check that runs git log -- '*/logs/*' on every doctor run: it is a full-history walk on someone's memory store, and its answer can never become "no".

That is a recommendation. It is your call, and it was correctly reserved as yours.

…shing 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>
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>
@fdaviddpt
fdaviddpt merged commit abc3c8c into main Aug 1, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/288-history-disclosure branch August 1, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stores that already pushed logs/ still carry them in the backup remote's history, and #287's exclusion cannot remove them

1 participant