pipwave-ekyc-uikit 3.2.1 → 3.2.2
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.
- package/.claude/settings.local.json +5 -4
- package/dist/pw-bundle.js +1 -1
- package/package.json +1 -1
- package/CODE_REVIEW_sc-345185.md +0 -102
package/package.json
CHANGED
package/CODE_REVIEW_sc-345185.md
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# Code Review — `feature-teojunjie-sc-345185-fix-face-detection-deadlock`
|
|
2
|
-
|
|
3
|
-
**Base:** `origin/master` · **Head:** `61f7559`
|
|
4
|
-
**Scope:** `src/plugins/face-detection.ts` (+105/-22), `src/plugins/face-detection.test.ts` (new, +227)
|
|
5
|
-
|
|
6
|
-
Two commits: (1) fix selfie face-detection deadlock + hint flicker via a per-frame
|
|
7
|
-
position-hint debounce (`confirmPositionState`) and one-sided top-containment slack;
|
|
8
|
-
(2) apply the forehead-overestimate correction to the fill-ratio checks too
|
|
9
|
-
(`FACE_HEIGHT_MULTIPLIER` 1.6 → 1.3).
|
|
10
|
-
|
|
11
|
-
The debounce logic, the `disableDetection`/reset wiring, and the cross-file surface
|
|
12
|
-
all check out — every changed method and event name is private to the SDK, and the
|
|
13
|
-
public `listenTo*` callback contracts are unchanged, so no external caller breaks.
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## Findings
|
|
18
|
-
|
|
19
|
-
### 1. Shipped failing test — `isFaceDetected` top-overflow guard is not actually enforced (CONFIRMED, high)
|
|
20
|
-
|
|
21
|
-
**File:** [src/plugins/face-detection.test.ts:72](src/plugins/face-detection.test.ts#L72) (root cause in [src/plugins/face-detection.ts:34](src/plugins/face-detection.ts#L34) / [:248](src/plugins/face-detection.ts#L248))
|
|
22
|
-
|
|
23
|
-
The new test `"still rejects a face with a genuine top overflow beyond estimate noise"`
|
|
24
|
-
asserts `isFaceDetected(pos)` is `false`, but it returns `true`. **`vitest run` fails
|
|
25
|
-
(1 failed / 7 passed).**
|
|
26
|
-
|
|
27
|
-
The test face has top landmark `y = 68`, `h = 170`. The new top check is:
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
withinTop = posFace.y - foreheadPadding > posCircle.y - topSlack
|
|
31
|
-
= 68 - (170*0.6) > 0 - (170*0.3)
|
|
32
|
-
= 68 - 102 > -51
|
|
33
|
-
= -34 > -51 → true (face accepted)
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Reducing to the effective requirement: `posFace.y > posCircle.y + 0.3*h`. The `0.3`
|
|
37
|
-
slack cancels half of the `0.6` forehead padding, so the top-containment guard only
|
|
38
|
-
requires ~0.3h of forehead clearance, not 0.6h. The face the author considered a
|
|
39
|
-
"genuine top crop" (`y=68`) still passes.
|
|
40
|
-
|
|
41
|
-
This is two problems in one:
|
|
42
|
-
- **CI is red** — a failing test is being committed.
|
|
43
|
-
- The comment at [:32-33](src/plugins/face-detection.ts#L32-L33) claims "a genuine top
|
|
44
|
-
crop (well beyond estimate noise) still fails" — the test demonstrates it does not.
|
|
45
|
-
Either `TOP_CONTAINMENT_SLACK_RATIO` (0.3) is too large, or the test's coordinates
|
|
46
|
-
are wrong. Decide which behavior is intended and align code + test.
|
|
47
|
-
|
|
48
|
-
**Failure scenario:** run `npm test`; the suite fails. In production, a face whose top
|
|
49
|
-
sits well above the intended forehead margin is accepted as "in frame".
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
### 2. `TOP_CONTAINMENT_SLACK_RATIO` comment does not match its value (low, maintainability)
|
|
54
|
-
|
|
55
|
-
**File:** [src/plugins/face-detection.ts:30-34](src/plugins/face-detection.ts#L30-L34)
|
|
56
|
-
|
|
57
|
-
The comment justifies the constant as "~0.1 covers the padding's average-case
|
|
58
|
-
overestimate (0.6 - 0.5); the rest is margin," but the value is `0.3` — i.e. 0.1 of
|
|
59
|
-
correction and 0.2 of pure leniency. Because this same 0.3 is also what defeats half
|
|
60
|
-
the forehead padding (finding #1) and is folded into `FACE_HEIGHT_MULTIPLIER = 1 + 0.6
|
|
61
|
-
- 0.3 = 1.3`, the effective assumption becomes "forehead ≈ 0.3h" everywhere. That is
|
|
62
|
-
internally consistent, but the stated reasoning (overestimate is only ~0.1) argues for
|
|
63
|
-
a much smaller slack. Reconcile the comment with the number so the next tuner isn't
|
|
64
|
-
misled about how much margin is deliberate.
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
### 3. Sustained oscillation between two failing position states can strand a stale hint (PLAUSIBLE, low)
|
|
69
|
-
|
|
70
|
-
**File:** [src/plugins/face-detection.ts:402-412](src/plugins/face-detection.ts#L402-L412)
|
|
71
|
-
|
|
72
|
-
`confirmPositionState` resets `candidatePositionCount` to 1 whenever the candidate
|
|
73
|
-
differs from the previous frame. If two *different* failing checks alternate every
|
|
74
|
-
frame (e.g. `faceTooClose` ↔ `faceTooFar` near their thresholds), neither ever reaches
|
|
75
|
-
`STABLE_FRAMES_TO_CHANGE_POSITION = 2`, so no new hint is emitted and `lastHintEvent`
|
|
76
|
-
stays at whatever was shown last — potentially a stale smile-stage prompt
|
|
77
|
-
(`userNoSmile`) while the face is actually mispositioned.
|
|
78
|
-
|
|
79
|
-
**Failure scenario:** user hovers at a distance where jitter flips between "too close"
|
|
80
|
-
and "too far" frame-to-frame; the on-screen guidance freezes on the previous message
|
|
81
|
-
instead of prompting a correction. Lower likelihood (jitter usually stays in one
|
|
82
|
-
category), but worth a bounded fallback if observed in the field.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
### 4. Formatting nits (trivial)
|
|
87
|
-
|
|
88
|
-
**File:** [src/plugins/face-detection.ts:413](src/plugins/face-detection.ts#L413), [:417](src/plugins/face-detection.ts#L417)
|
|
89
|
-
|
|
90
|
-
- Line 413 has trailing whitespace.
|
|
91
|
-
- Missing blank lines between `confirmPositionState`, `resetPositionDebounce`, and
|
|
92
|
-
`checkFace` (methods run together). Cosmetic; align with the spacing used elsewhere
|
|
93
|
-
in the class.
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## Verification performed
|
|
98
|
-
|
|
99
|
-
- `vitest run src/plugins/face-detection.test.ts` under Node 22 → **1 failed, 7 passed**
|
|
100
|
-
(finding #1 reproduced directly).
|
|
101
|
-
- Cross-file caller trace (`uisdk.ts`, `face-camera.ts`): no signature/contract breakage;
|
|
102
|
-
only hint timing/thresholds shift, as intended.
|