Skip to content

fix(likes): prune spent records from flags.json - #249

Merged
jamesconwaydev merged 1 commit into
devstreamhq:mainfrom
foothillsdigital:fix/prune-flags-trust
Nov 6, 2026
Merged

jamesconwaydev merged 1 commit into
devstreamhq:mainfrom
foothillsdigital:fix/prune-flags-trust

Conversation

@foothillsdigital

Copy link
Copy Markdown
Collaborator

What and why

Closes #44.

flags.json. The hourly write lays this run's new and changed records over the stored copy, so nothing was ever removed. _merge_flags now also drops records nothing reads again:

  • Entries off the list. The key isn't in entries.json at all. Hidden, archived and other entries still on the list keep theirs.
  • Reviewed and past the cooldown. reviewed_at is set and older than COOLDOWN[kind] (1 day for a burst, 7 for a drip). _due already treats that the same as no record, so the next burst or drip opens an issue exactly as before.

Unreviewed records are never pruned while their entry is listed. Only records this run has seen get pruned. On a 409 re-read, a record another writer added since is left for the next run. My first version pruned those too, and test_flags_409_then_success_keeps_both_records caught it: rot moving a renamed entry's flags to the new key could have been undone by a sync that read the old list. A rename in flight already stops sync before any write (_rename_in_flight), so the old key isn't pruned mid-rename either.

Trust cache. This half already landed in 7df8824, after the issue was filed: each run writes back only entries still inside their refresh age (cache.get(k, now) is not None). Nothing to change there.

Dry run. I read the live flags.json from stats and ran the new merge against the current entries.json. It's empty right now, so this prunes nothing today.

New test: a mix of records with a burst inside and past its cooldown, a drip inside and past its cooldown, and a pending record for a removed entry. Exactly the spent ones are dropped, a hidden entry keeps its live record, and the next run writes nothing. It fails on main.

Checks

  • The PR title follows Conventional Commits
  • python3 -m unittest discover -s scripts -t . passes (598)
  • npm --prefix site test passes (if you touched site/)
  • npx prettier --check . passes
  • This doesn't edit data/entries.json by hand (submissions go through the form)

@jamesconwaydev jamesconwaydev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean. Pruning only on exactly the test _due already uses means nothing about when issues open can change, and only touching records this run saw is the right answer to the 409 case. Good that the existing test caught the first version. I'll merge once CI is green.

@jamesconwaydev

Copy link
Copy Markdown
Collaborator

Same story as #207: the fuzz failure came from a fuzz target that didn't know about the emoji joiner from #203. #250 fixes it. Could you rebase once more? I'll merge as soon as it's green.

flags.json only ever grew: each hourly write laid this run's records
over the stored copy and never removed anything. The write now also
drops records nothing reads again: those for entries no longer in
entries.json, and reviewed ones whose cooldown has run out (1 day for
a burst, 7 for a drip), which _due already treats the same as no
record.

Only records this run has seen are pruned. On a 409 re-read, a record
another writer added since (rot moving a renamed entry's key, say)
is left alone, since this run's list may not know that name yet.

The trust cache half of the issue already landed in 7df8824, which
drops entries past their TTL on every write.
@jamesconwaydev
jamesconwaydev merged commit 85be7cd into devstreamhq:main Nov 6, 2026
8 checks passed
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.

Prune flags.json and the trust cache

2 participants