sessionevidence

package
v2.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package sessionevidence turns a host's privacy-filtered foreground/screen/ keyguard observations into proven, closed play intervals. It has no database or platform dependency: every rule here is pure so it can be replayed and tested without a store.

Index

Constants

View Source
const ForegroundGraceMs int64 = 2000

ForegroundGraceMs is the same-package pause/resume grace period: an emulator's own menu or a brief activity transition does not fragment a session. It is a versioned policy constant, not catalog data.

View Source
const PolicyVersion = 1

PolicyVersion is stamped on every segment this package produces, so a later change to the grace period or state machine never reinterprets already-closed intervals.

Variables

This section is empty.

Functions

This section is empty.

Types

type ForegroundEvent

type ForegroundEvent struct {
	Kind        ForegroundKind
	TimestampMs int64
}

ForegroundEvent is already filtered by the host to one target package (never a specific activity - a launch whose intent forwards through more than one activity of the same app must still read as one session) plus anonymous screen/keyguard transitions. Events must be supplied in query (timestamp) order.

type ForegroundKind

type ForegroundKind string

ForegroundKind is the privacy-filtered vocabulary of host observations. It carries no unrelated package identity.

const (
	TargetResumed        ForegroundKind = "target_resumed"
	TargetPaused         ForegroundKind = "target_paused"
	TargetStopped        ForegroundKind = "target_stopped"
	OtherResumed         ForegroundKind = "other_resumed"
	ScreenInteractive    ForegroundKind = "screen_interactive"
	ScreenNonInteractive ForegroundKind = "screen_non_interactive"
	KeyguardShown        ForegroundKind = "keyguard_shown"
	KeyguardHidden       ForegroundKind = "keyguard_hidden"
)

type ForegroundResult

type ForegroundResult struct {
	Status      string
	Segments    []ForegroundSegment
	OpenStartMs int64
	ConfirmedMs int64
	ClosedMs    int64
	Confirmed   bool
}

ForegroundResult contains only proven, closed play intervals. OpenStartMs is diagnostic state and must not be synced as completed exact playtime.

func ReconcileForeground

func ReconcileForeground(
	requestedMs, queryEndMs, hardCloseAtMs int64, events []ForegroundEvent,
) (ForegroundResult, error)

ReconcileForeground replays retained normalized observations from a launch. Replaying the same overlapping batch is idempotent. Missing screen/keyguard state never becomes evidence that gameplay was visible.

hardCloseAtMs is 0, or the timestamp another recorded launch proved this one's target could no longer be current: unlike queryEndMs, which only says how far Core has looked so far and is never proof of an end, this is proof, so any interval still open at that point is force-closed there instead of staying an unconfirmed diagnostic guess.

func (ForegroundResult) ClosedDurationMs

func (r ForegroundResult) ClosedDurationMs() int64

type ForegroundSegment

type ForegroundSegment struct {
	StartMs int64
	EndMs   int64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL