flexitracker 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flexitracker-0.5.0 → flexitracker-0.5.1}/.gitignore +4 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/PKG-INFO +1 -1
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/idle.py +10 -4
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/state_machine.py +23 -3
- flexitracker-0.5.1/tests/vectors/25-heartbeat-does-not-clamp-idle-backdate.json +14 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/LICENSE +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/README.md +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/install/README.md +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/install/flexitracker.service +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/pyinstaller_entry.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/pyproject.toml +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/__init__.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/__main__.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/_backend.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/cli.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/config.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/core.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/logging_setup.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/login.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/outbox.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/sender.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/src/flexitracker/version.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_cli.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_config.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_conformance.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_idle.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_logging_setup.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_login.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_outbox.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/test_sender_body.py +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/01-activation-debounced-backdated.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/02-idle-backdated-to-last-input.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/03-short-break-absorbed.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/04-brief-activity-debounced.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/05-sustained-return-backdated.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/06-heartbeats-while-active.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/07-recover-after-sudden-shutdown.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/08-locked-session-goes-idle.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/09-recover-anchors-later-evidence.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/10-suspend-longer-closes-span.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/11-suspend-with-immediate-wake.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/12-suspend-shorter-absorbed.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/13-backwards-clock-watermark.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/14-small-forward-clock-absorbed.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/15-recover-from-active-matches-loop.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/16-explicit-close-no-double-close.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/17-freshness-independent-of-poll.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/18-short-reading-pause.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/19-presence-must-be-sustained.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/20-gap-kills-pending-return.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/21-idle-backdating-exact.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/22-min-inactivity-exact-boundary.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/23-large-timestamps.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/24-all-kinds-lowercase.json +0 -0
- {flexitracker-0.5.0 → flexitracker-0.5.1}/uv.lock +0 -0
|
@@ -173,10 +173,16 @@ class WindowsIdle:
|
|
|
173
173
|
def __init__(self) -> None:
|
|
174
174
|
self._user32 = ctypes.windll.user32 # type: ignore[attr-defined]
|
|
175
175
|
self._kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
# windows_session_locked() (WTSQuerySessionInformationW/WTSSessionInfoEx,
|
|
177
|
+
# below) is DISABLED — see CLAUDE.md. Its struct-offset read was never
|
|
178
|
+
# verified on real Windows hardware and, in production, it returned
|
|
179
|
+
# "locked" on the very first poll and never once returned "unlocked"
|
|
180
|
+
# again across 6 days / 20,000+ polls — not imprecise, structurally
|
|
181
|
+
# incapable of ever confirming activity again, since input_fresh()
|
|
182
|
+
# requires `not locked`. Hardcoded to None (idle_ms-only, the
|
|
183
|
+
# known-safe pre-v0.5.0 behavior) until this is fixed AND actually
|
|
184
|
+
# verified against real hardware, not just reasoned about.
|
|
185
|
+
self._wtsapi32 = None
|
|
180
186
|
|
|
181
187
|
def sample(self) -> Sample:
|
|
182
188
|
info = _LASTINPUTINFO()
|
|
@@ -83,14 +83,34 @@ class StateMachine:
|
|
|
83
83
|
self.p = persisted
|
|
84
84
|
|
|
85
85
|
def emit(self, ts: int, kind: str) -> dict:
|
|
86
|
-
"""Emit
|
|
87
|
-
|
|
86
|
+
"""Emit a span-boundary event (active/idle), holding the monotonic
|
|
87
|
+
watermark so no path can emit one out of order relative to the last.
|
|
88
|
+
Heartbeats go through `emit_heartbeat` instead, deliberately NOT
|
|
89
|
+
through here: the backend pairs spans from active/idle ts alone
|
|
90
|
+
(`pairSpans` in worktime.ts) and never requires an idle ts to be at or
|
|
91
|
+
after some prior heartbeat's ts — a heartbeat is a wall-clock liveness
|
|
92
|
+
ping, not a span boundary. Letting a heartbeat raise this watermark
|
|
93
|
+
used to force a legitimately earlier, correctly back-dated idle close
|
|
94
|
+
forward to the last heartbeat's ts — which happened on essentially
|
|
95
|
+
every idle transition at default settings, since heartbeat_ms (5 min)
|
|
96
|
+
is shorter than min_inactivity_ms (10 min), so a heartbeat has always
|
|
97
|
+
fired since the real last input by the time idle_long confirms.
|
|
98
|
+
Observed in production: an active span's real last input was 14:01:33,
|
|
99
|
+
confirmed idle at 14:11:42, and got reported as ending 14:07:11 (the
|
|
100
|
+
last heartbeat) instead — see CLAUDE.md."""
|
|
88
101
|
prev = self.p.last_emitted_ts
|
|
89
102
|
if prev is not None and ts < prev:
|
|
90
103
|
ts = prev
|
|
91
104
|
self.p.last_emitted_ts = ts
|
|
92
105
|
return event(ts, kind)
|
|
93
106
|
|
|
107
|
+
def emit_heartbeat(self, ts: int) -> dict:
|
|
108
|
+
"""A wall-clock liveness ping, not a span boundary — see `emit`. `ts`
|
|
109
|
+
is always `tick.now` (never back-dated), so it never needs the
|
|
110
|
+
backwards-clock clamp for itself, and must not raise the watermark
|
|
111
|
+
that clamps a later active/idle back-date."""
|
|
112
|
+
return event(ts, EventKind.HEARTBEAT)
|
|
113
|
+
|
|
94
114
|
def input_fresh(self, tick: Tick) -> bool:
|
|
95
115
|
return (not tick.locked) and tick.idle_ms < FRESH_INPUT_MS
|
|
96
116
|
|
|
@@ -206,7 +226,7 @@ class StateMachine:
|
|
|
206
226
|
"-> heartbeat due (last_heartbeat=%s heartbeat_ms=%d)",
|
|
207
227
|
self.p.last_heartbeat, self.t.heartbeat_ms,
|
|
208
228
|
)
|
|
209
|
-
out.append(self.
|
|
229
|
+
out.append(self.emit_heartbeat(tick.now))
|
|
210
230
|
self.p.last_heartbeat = tick.now
|
|
211
231
|
else: # IDLE
|
|
212
232
|
# "Activity persisted for min_activity" must tolerate short pauses.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "heartbeat_does_not_clamp_a_later_idle_backdate",
|
|
3
|
+
"description": "A heartbeat between the real last input and the confirmed idle close must not force the idle close's back-dated ts forward to the heartbeat's ts. Reproduces a production incident: real last input 14:01:33, confirmed idle 14:11:42, incorrectly reported as ending 14:07:11 (the last heartbeat) instead of 14:01:33.",
|
|
4
|
+
"initial": { "reported_state": "Active", "last_active_time": 0, "last_emitted_ts": 0 },
|
|
5
|
+
"steps": [
|
|
6
|
+
{ "op": "tick", "now": 300000, "idle_ms": 300000 },
|
|
7
|
+
{ "op": "tick", "now": 600000, "idle_ms": 600000 }
|
|
8
|
+
],
|
|
9
|
+
"expected": [
|
|
10
|
+
{ "kind": "heartbeat", "ts": 300000 },
|
|
11
|
+
{ "kind": "idle", "ts": 0 }
|
|
12
|
+
],
|
|
13
|
+
"expected_final": { "reported_state": "Idle" }
|
|
14
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/01-activation-debounced-backdated.json
RENAMED
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/02-idle-backdated-to-last-input.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/07-recover-after-sudden-shutdown.json
RENAMED
|
File without changes
|
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/09-recover-anchors-later-evidence.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/14-small-forward-clock-absorbed.json
RENAMED
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/15-recover-from-active-matches-loop.json
RENAMED
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/16-explicit-close-no-double-close.json
RENAMED
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/17-freshness-independent-of-poll.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flexitracker-0.5.0 → flexitracker-0.5.1}/tests/vectors/22-min-inactivity-exact-boundary.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|