Skip to content

# Issue — Implement should_trigger_reasoning() Phase 4 gate #42

@Devnil434

Description

@Devnil434

Description

Before triggering the VLM/LLM reasoning layer, the pipeline must determine
whether a track is important enough to reason about.

Without this gate, the VLM would run on every frame and significantly slow
down the pipeline.

Implement:

should_trigger_reasoning(seq: TrackSequence) -> bool

inside:

services/memory/trigger.py

Requirements

Return True only when ALL conditions are satisfied:

  1. Track is inside a restricted zone

  2. Dwell time exceeds configured threshold

  3. At least one suspicious action exists:

    • LINGERING
    • NEAR_KEYPAD
    • REPEATED_APPROACH
  4. Track is not inside cooldown window


Additional Function

Also implement:

reset_cooldown(track_id: int)

to clear cooldown state after reasoning completes.


Constraints

  • Pure in-memory logic only
  • No Redis calls
  • Cooldown duration: 5 seconds
  • Thresholds should come from centralized settings

Acceptance Criteria

  • Returns False below dwell threshold
  • Returns False during cooldown
  • Returns True for suspicious sequences
  • Add 6 unit tests covering all branches
  • Existing tests remain green

Helpful Context

Relevant modules:

services/memory/trigger.py
services/memory/pipeline.py
libs/schemas/memory.py

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions