Commit graph

141 commits

Author SHA1 Message Date
유창욱
450c88978f fix(cloud): session-id regeneration on login (fixation) + pristine test output 2026-07-12 00:35:41 +09:00
유창욱
b345a89788 feat(cloud): session store + auth controller with lockout 2026-07-12 00:28:18 +09:00
유창욱
9983bc8fe3 feat(cloud): RBAC permission matrix 2026-07-12 00:19:47 +09:00
유창욱
76ea1b4ecf feat(cloud): argon2id password + CSRF token helpers 2026-07-12 00:11:20 +09:00
유창욱
185629a4c4 fix(cloud): unify ingest auth errors (anti-enumeration) + guard snapshot write 2026-07-12 00:07:42 +09:00
유창욱
57cfc64548 feat(cloud): ingest controller (HMAC+nonce+ratelimit+reencode+persist) 2026-07-12 00:01:05 +09:00
유창욱
a0db1e06ca feat(cloud): Http Request/Response primitives 2026-07-11 23:54:58 +09:00
유창욱
7246e12c4a feat(cloud): gd image re-encode (strip payload, uuid, hash) 2026-07-11 23:50:08 +09:00
유창욱
2f88355071 fix(cloud): type-guard EventValidator fields against malformed input 2026-07-11 23:46:38 +09:00
유창욱
b5388b2a68 feat(cloud): event payload validator with enum whitelist 2026-07-11 23:40:53 +09:00
유창욱
4bbd28f95f fix(cloud): centralize test-double autoloading via composer files
Move InMemoryRepositories.php from require_once workaround to composer
files-autoload. Enables PSR-4 autoloading of test-double classes and
scales for 5+ future test files. All 8 tests pass with require_once removed.
2026-07-11 23:38:01 +09:00
유창욱
67b9999a31 feat(cloud): repository interfaces + in-memory test doubles 2026-07-11 23:32:16 +09:00
유창욱
6fbe4015dc test(cloud): golden HMAC vectors proving P1-A Python interop 2026-07-11 23:25:15 +09:00
유창욱
8e62304471 feat(cloud): HMAC sign/verify matching P1-A edge contract 2026-07-11 23:21:00 +09:00
유창욱
50cb2cfe82 feat(cloud): P1-B scaffold — composer autoload + Config 2026-07-11 23:16:13 +09:00
유창욱
65344f6ea6 docs: P1-B cloud ingest + dashboard implementation plan
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ne4rU4FToTLHcBUMUvUnT1
2026-07-11 23:12:04 +09:00
유창욱
e81ea8961c refactor(edge): DRY displacement helper into geometry.track_displacement (FIX 6)
_displacement (mean per-keypoint delta between the last two track frames,
normalized by bbox height) was duplicated verbatim in
edge/detectors/fall.py and edge/detectors/immobility.py.

Move it to edge/geometry.py as track_displacement(track) and have both
detectors call the shared helper instead of their own private copy.
Pure refactor — behavior is identical (byte-identical formula), no
config or public API changes.

Tests: tests/test_geometry.py adds direct coverage for the new public
helper (fewer-than-two-frames default, and the normalized-by-height
calculation). Existing fall/immobility tests are unchanged and stay green,
confirming behavior parity.
2026-07-11 22:21:27 +09:00
유창욱
752aabaff1 fix(edge): forget per-track state on lost tracks (FIX 5)
fall._states, immobility._still_since/_fired, zone._inside_since/_fired,
and engine._last_emit were never pruned when a track was lost (ghost
already pruned via on_lost). On a 24/7 edge device this is unbounded
growth as track IDs keep incrementing.

Add forget(track_id) to FallDetector, ImmobilityWatchdog, and
ZoneIntrusionDetector (drops that track's per-track keys/sets).
EventEngine.forget(track_id) calls each sub-detector's forget and removes
_last_emit cooldown keys whose tuple's second element is that track_id
(covers FALL/NO_MOTION/IMMOBILITY/zone/GHOST — GHOST keys are
(GHOST, track_id) after FIX 4). EventEngine.process now calls
self.forget(tr.track_id) for every track in lost_tracks after emitting,
since ghost.on_lost already consumed that track's ghost-relevant state at
the top of process().

app.py run_once already calls pool.forget(tr.track_id) for lost tracks as
part of FIX 1, completing the cleanup chain (smoother pool + detector
state + dedup cache).

Tests: tests/test_engine.py adds test_forget_prunes_state_on_lost —
fires a FALL event, then passes the track as lost, and asserts
engine._last_emit no longer has that track's keys and fall._states no
longer has the track id.
2026-07-11 22:19:39 +09:00
유창욱
f7266f5980 fix(edge): identity-aware GHOST dedup keyed on track_id (FIX 4)
edge/engine.py keyed the ghost cooldown as
(GHOST, round(x), round(y)) — purely spatial, ignoring track identity.
Two distinct workers collapsing at ~the same pixel within the cooldown
window would suppress each other's ghost event, potentially masking a
second CRITICAL incident.

edge/detectors/ghost.py GhostIncidentDetector.update now includes the
candidate's track_id in each emitted dict. edge/engine.py keys the
cooldown as (EventType.GHOST, track_id) and sets the emitted Event's
track_id accordingly, matching how FALL/NO_MOTION/IMMOBILITY/zone events
are already keyed per-track.

Tests: tests/test_ghost.py asserts ghosts[0]["track_id"] == 1 on the
existing reappear-timeout test.
2026-07-11 22:17:48 +09:00
유창욱
f46ed40088 fix(edge): populate Event.duration_s from detector metrics (FIX 3)
edge/engine.py _mk hardcoded duration_s=0.0 for every event. The §7.3
wire contract / P1-B dashboard expects the real incident duration for
no_motion, immobility, and ghost events.

_mk now derives duration_s from the metrics dict: immobility_s (fall
no_motion, immobility watchdog) or waited_s (ghost), falling back to 0.0
for instantaneous confirms (fall, zone).

Tests: tests/test_engine.py adds test_no_motion_event_carries_duration,
driving a track to NO_MOTION and asserting the emitted event's duration_s
is > 0 and equals metrics["immobility_s"].
2026-07-11 22:16:44 +09:00
유창욱
3240428380 fix(edge): require sustained non-prone before FallDetector recover (FIX 2)
edge/detectors/fall.py update(): a single frame where prone was false while
state was in {FALLING, FALLEN, NO_MOTION} immediately emitted "recover" and
reset _State. One jittery frame (a momentary pose-estimation miss) could
wipe an in-progress CRITICAL no_motion incident.

Add FallConfig.recover_grace_s (default 1.0s) and _State.not_prone_since.
On the first non-prone frame while in an incident state, start the grace
timer instead of recovering immediately; only reset to STANDING once
recover_grace_s of sustained non-prone has elapsed. A re-prone frame while
in an incident state clears the pending grace timer (cancels the recover
attempt). The non-incident STANDING path is unchanged.

BEHAVIOR CHANGE: recover now requires recover_grace_s of sustained
non-prone instead of firing on a single frame.

Tests: test_recovery_clears_state (tests/test_fall.py) strengthened per
review brief to assert a single standing frame does NOT recover but
sustained standing across the grace window does. Added
test_single_noisy_nonprone_frame_does_not_cancel_no_motion covering the
life-safety scenario: one noisy non-prone frame during NO_MOTION must not
cancel the incident.
2026-07-11 22:15:47 +09:00
유창욱
01c7f4636e fix(edge): smooth keypoints per-track after tracking, not before (FIX 1)
edge/app.py run_once used ONE shared KeypointSmoother across all persons
BEFORE tracking assigned IDs. The smoother holds per-joint-index One-Euro
filter state, so with >1 person in frame the filter state was shared and
corrupted across different people, and same-timestamp calls within a frame
would pass through unsmoothed while still clobbering the shared state.
Multi-person scenes could get corrupted torso angles -> missed/false falls.

Add TrackSmootherPool (edge/smoothing.py) that lazily allocates one
KeypointSmoother per track_id. run_once now: tracks raw keypoints first,
then smooths each track's latest frame in place using its own pooled
smoother, and forgets a track's smoother when the track is lost (ties into
FIX 5 lost-track cleanup).

BEHAVIOR CHANGE: keypoints are now smoothed after tracking instead of
before. Single-person pipelines are unaffected (still one smoother, one
identity). Multi-person pipelines get correct, non-cross-contaminated
smoothing.

run_once signature: smoother param replaced with pool: TrackSmootherPool.
build_pipeline now constructs "pool" instead of "smoother".

Tests: tests/test_smoothing.py adds TrackSmootherPool identity/forget
coverage; tests/test_app.py adds test_two_persons_get_independent_smoothing
demonstrating each track's smoothed keypoints stay on its own side instead
of being pulled toward the other person.
2026-07-11 22:14:03 +09:00
유창욱
2ac26d4091 feat(edge): hardware adapter stubs + Pi bring-up/benchmark doc 2026-07-11 21:54:24 +09:00
유창욱
b621627863 feat(edge): main-loop wiring (run_once) + pipeline factory 2026-07-11 21:46:43 +09:00
유창욱
e74cc7f898 test(edge): cover ghost/zone env overrides and config defaults 2026-07-11 21:43:35 +09:00
유창욱
a63a5918cc feat(edge): env-based Config for detectors and transport 2026-07-11 21:40:06 +09:00
유창욱
bfff96ddbd feat(edge): OfflineQueue (SQLite persist + ordered resend) 2026-07-11 21:33:43 +09:00
유창욱
67464971bf feat(edge): PostClient with HMAC+nonce signed event POST 2026-07-11 21:27:38 +09:00
유창욱
5da838ef0b feat(edge): RingBuffer + face blur + JPEG snapshotter 2026-07-11 21:21:57 +09:00
유창욱
e801c7d057 test(edge): add genuine EventEngine cooldown primitive test 2026-07-11 21:18:27 +09:00
유창욱
e8e24c266f feat(edge): EventEngine orchestration with dedup + cooldown 2026-07-11 21:12:43 +09:00
유창욱
406c0f5b6c feat(edge): ZoneIntrusionDetector (foot-anchor point-in-polygon, debounce) 2026-07-11 21:05:42 +09:00
유창욱
3bcfdea11d feat(edge): GhostIncidentDetector (collapse-then-occluded spatial incident) 2026-07-11 20:59:31 +09:00
유창욱
bd170c4803 feat(edge): ImmobilityWatchdog (posture-independent prolonged immobility) 2026-07-11 20:51:33 +09:00
유창욱
5545b26779 feat(edge): FallDetector state machine (OR-logic, baseline freeze, post-fall no-motion) 2026-07-11 20:41:11 +09:00
유창욱
1020304dca feat(edge): Event model + severity mapping (§7.3 payload) 2026-07-11 20:34:57 +09:00
유창욱
02ca524bf6 feat(edge): Track model + IoU tracker with lost-track reporting 2026-07-11 20:28:45 +09:00
유창욱
991178a896 feat(edge): One-Euro keypoint smoothing (INT8 jitter) 2026-07-11 20:23:21 +09:00
유창욱
444c01407a feat(edge): pose geometry utils (torso angle, com, normalization) 2026-07-11 20:18:03 +09:00
유창욱
33e987d8d9 feat(edge): data models (Keypoint, BBox, Person) + COCO indices 2026-07-11 20:13:00 +09:00
유창욱
a4f2ead211 docs: workplace safety AI CCTV design spec v2.0 + P1-A edge core plan
- 설계 스펙 v2.0 (다관점 리뷰 반영: 기절경로 분리, 시점강건 낙상, 인증/RBAC, 평가셋, fps 3티어, 컴플라이언스, 증거 무결성)
- P1-A 엣지 감지 코어 구현계획 (16 태스크 TDD)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ne4rU4FToTLHcBUMUvUnT1
2026-07-11 20:08:01 +09:00