One function
_pages_for_segment in nossa-y/activity-frames
The author described this change as “fix(frames): fix page count misattribution on revisit-then-dwell (#31) (#33)”. It counts as a record because the check below fails on the code as it stood at f8ef36c9c and passes on 465d8d9b0, with nothing else changed between the two runs.
Projectnossa-y/activity-frames
Fix saved2026-08-01
Sharing licenceMIT · LICENSE
Change size+1 −8
What the code was meant to do, written into the code itself as a docstring
Aggregate URL views in a segment into typed page references.
The change
| 1 | 1 | def _pages_for_segment(seg: Segment) -> list[PageView]: | |
| 2 | - | """Aggregate consecutive URL views into typed page references.""" | |
| 2 | + | """Aggregate URL views in a segment into typed page references.""" | |
| 3 | 3 | views: list[PageView] = [] | |
| 4 | 4 | index: dict[tuple[str, str | None], PageView] = {} # O(1) duplicate lookup | |
| 5 | - | last_key: tuple[str, str | None] | None = None | |
| 6 | 5 | for f in seg.frames: | |
| 7 | 6 | if not f.url: | |
| 8 | 7 | continue | |
| 9 | 8 | ref = parse_url(f.url) | |
| 10 | 9 | key = (ref.kind, ref.entity) | |
| 11 | - | if last_key == key and views: | |
| 12 | - | views[-1].count += 1 | |
| 13 | - | continue | |
| 14 | - | # Re-visit of an earlier page in the same segment: bump it instead | |
| 15 | - | # of appending a duplicate entry. | |
| 16 | 10 | existing = index.get(key) | |
| 17 | 11 | if existing is not None: | |
| 18 | 12 | existing.count += 1 | |
| ⋯ | |||
| 20 | 14 | pv = PageView(kind=ref.kind, entity=ref.entity, count=1) | |
| 21 | 15 | views.append(pv) | |
| 22 | 16 | index[key] = pv | |
| 23 | - | last_key = key | |
| 24 | 17 | return views | |
The check that tells the two apart
fail→pass·tests/test_frames_emit.py::test_pages_for_segment_revisit_then_dwell
Check file tests/test_frames_emit.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itf8ef36c9c2f387a9b7bed1cb1b95b55cc773473f
Broken version dated2026-08-01
Moduleactivity_frames.frames
Units changed_pages_for_segment
Fingerprintc0e4cbcd39c64f0e
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.