Commit 07c2032
committed
fix(accounts): signal removed-current instead of silent retarget (HI-04)
PR #413 hardened removeAccount pointer normalization so the current
pointer no longer defaults to -1 when the active account is removed
while other accounts remain in the pool. It did so by retargeting the
pointer onto the successor account at the post-splice slot, which
silently substitutes a different account for the caller's "current"
without any audit trail.
HI-04 (from .sisyphus/notepads/deep-audit/reports/accounts-rotation.json)
flagged this as a correctness issue: getCurrentAccountForFamily()
returns an account the caller never selected, with no lastSwitchReason
indicating that the pool chose it. This masks pool-driven retargets in
logs, dashboards, and session-affinity consumers that key on
lastSwitchReason to distinguish user-selected from pool-selected
identities.
Fix: when removeAccount retargets the active pointer off the removed
slot onto a new successor (priorActive[family] === idx), stamp
lastSwitchReason="rotation" on that successor. This mirrors the
existing convention already used by setActiveIndex() and markSwitched()
for pool-driven selection events, so downstream observers see a
consistent retarget signal instead of the successor's stale prior
reason.
Successors are deduped across families (lastSwitchReason is per-account,
not per-family) via a Set, and the signal is only applied when we
actually retargeted off the removed slot. If the pool collapses to no
routable account (every remaining peer disabled), no successor is
stamped and the pointer falls to -1 — matching the "no routable
account" contract PR #413 established.
Tests (test/accounts.test.ts "removed-current retarget signal (HI-04)"):
- removing the currently active (middle) account stamps rotation on
the successor and leaves untouched peers with their prior reason
- removing the last enabled account when every remaining peer is
disabled yields pointer=-1 and does NOT stamp any disabled peer
- removing the currently active account with exactly one other enabled
peer (plus a disabled peer that findNextEnabled must skip) lands on
the enabled successor and stamps rotation only on it
Source: .sisyphus/notepads/deep-audit/reports/accounts-rotation.json HI-041 parent 3f1c1fe commit 07c2032
2 files changed
Lines changed: 153 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1316 | 1316 | | |
1317 | 1317 | | |
1318 | 1318 | | |
1319 | | - | |
1320 | | - | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
1321 | 1327 | | |
1322 | 1328 | | |
1323 | 1329 | | |
| |||
1336 | 1342 | | |
1337 | 1343 | | |
1338 | 1344 | | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
1339 | 1353 | | |
1340 | 1354 | | |
1341 | 1355 | | |
| |||
1358 | 1372 | | |
1359 | 1373 | | |
1360 | 1374 | | |
1361 | | - | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1362 | 1378 | | |
| 1379 | + | |
1363 | 1380 | | |
1364 | 1381 | | |
1365 | | - | |
| 1382 | + | |
1366 | 1383 | | |
1367 | 1384 | | |
1368 | 1385 | | |
1369 | 1386 | | |
1370 | 1387 | | |
1371 | 1388 | | |
1372 | 1389 | | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1373 | 1406 | | |
1374 | 1407 | | |
1375 | 1408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2890 | 2890 | | |
2891 | 2891 | | |
2892 | 2892 | | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
2893 | 3009 | | |
2894 | 3010 | | |
2895 | 3011 | | |
| |||
0 commit comments