Repository navigation
Commit facce31
committed
fix(codex): follow a rewritten replay burst past a second tick
When a forked session's parent log is not in the scanned set, the parser cannot
subtract the exact replayed prefix and falls back to skipping the burst Codex
rewrote to the fork instant. That fallback bucketed events by their recorded
second, so any burst written across a second tick was truncated and its
remainder counted as the child's own usage.
One real subagent log on hand reports 47,175,282 tokens through the fallback
against 19,820,638 when the parent log is present, a 2.4x over-count from 315
replayed records that landed in the second after the tick.
Follow the run instead of the second: skip while successive events stay within a
second of each other. Measured across the fork logs on hand, a rewritten burst
spans 10 to 40ms and the child's own first turn follows a pause of 5.8 to 15.3
seconds, so a second sits two orders of magnitude above the burst and well below
the pause.
Verified against 210 real fork sessions whose parent log could be located: the
fallback now returns the same totals as exact prefix subtraction for every one of
them, and a full scan is unchanged down to the cost figure.
`skips_missing_parent_replay_when_duplicate_snapshot_is_suppressed` placed the
child's own turn 800ms after the burst, which only read as the child's own under
second bucketing. Its subject is snapshot suppression, so the fixture now uses a
pause a real log would show and keeps testing that.
Closes the gap left by #1457.1 parent 24a3ed0 commit facce31
2 files changed
Lines changed: 102 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1721 | 1721 | | |
1722 | 1722 | | |
1723 | 1723 | | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
1724 | 1776 | | |
1725 | 1777 | | |
1726 | 1778 | | |
| |||
1841 | 1893 | | |
1842 | 1894 | | |
1843 | 1895 | | |
| 1896 | + | |
1844 | 1897 | | |
1845 | 1898 | | |
1846 | | - | |
| 1899 | + | |
| 1900 | + | |
1847 | 1901 | | |
1848 | 1902 | | |
1849 | 1903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
76 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
85 | 105 | | |
86 | 106 | | |
87 | | - | |
| 107 | + | |
88 | 108 | | |
89 | 109 | | |
90 | 110 | | |
| |||
111 | 131 | | |
112 | 132 | | |
113 | 133 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
121 | 137 | | |
122 | 138 | | |
123 | 139 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
127 | 147 | | |
128 | 148 | | |
129 | 149 | | |
| |||
176 | 196 | | |
177 | 197 | | |
178 | 198 | | |
179 | | - | |
| 199 | + | |
180 | 200 | | |
181 | | - | |
| 201 | + | |
182 | 202 | | |
183 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
184 | 207 | | |
185 | | - | |
186 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
187 | 214 | | |
188 | 215 | | |
189 | 216 | | |
| |||
0 commit comments