fix(v1): wire model confidence, explicit source mode, unique event ids

A: PoseAdapter.set_confidence_threshold is applied on start, so the
   settings model-confidence field actually affects inference.
B: config source.mode ('stream'|'replay') is explicit; app no longer
   guesses the source type from the URL prefix.
C: FallStateMachine takes a session_id and from_config generates a
   unique one per run, so event ids never collide across restarts
   (no screenshot overwrite or duplicate JSONL identity in a day).

51 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ila
2026-07-21 20:54:34 +08:00
co-authored by Claude Opus 4.8
parent 7443a8f031
commit 04422d9ca0
13 changed files with 188 additions and 7 deletions
+55
View File
@@ -46,6 +46,61 @@ def test_from_results_extracts_person_box_confidence_and_seventeen_keypoints():
assert poses[0].keypoints[5].confidence == 0.9
class _RecordingPoseModel:
task = "pose"
names = {0: "person"}
class model:
kpt_shape = (17, 3)
def __init__(self):
self.calls = []
def __call__(self, image, conf, verbose):
self.calls.append(conf)
class _Empty:
names = {0: "person"}
class boxes:
xyxy = []
conf = []
cls = []
class keypoints:
data = []
return _Empty()
def test_set_confidence_threshold_is_forwarded_to_inference(tmp_path):
weights = tmp_path / "pose.pt"
weights.write_bytes(b"fake-weights")
expected_sha256 = hashlib.sha256(weights.read_bytes()).hexdigest()
model = _RecordingPoseModel()
adapter = PoseAdapter(
weights, expected_sha256, confidence_threshold=0.25, model_factory=lambda _p: model
)
adapter.set_confidence_threshold(0.6)
adapter.infer(np.zeros((10, 10, 3), dtype=np.uint8))
assert adapter.confidence_threshold == 0.6
assert model.calls == [0.6]
def test_set_confidence_threshold_rejects_out_of_range(tmp_path):
weights = tmp_path / "pose.pt"
weights.write_bytes(b"fake-weights")
expected_sha256 = hashlib.sha256(weights.read_bytes()).hexdigest()
adapter = PoseAdapter(
weights, expected_sha256, model_factory=lambda _p: _RecordingPoseModel()
)
with pytest.raises(ModelValidationError):
adapter.set_confidence_threshold(1.5)
def test_pose_adapter_rejects_non_pose_model_after_hash_validation(tmp_path):
model_path = tmp_path / "model.pt"
model_path.write_bytes(b"model bytes")