You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
History listings disagree with the plain rebuild after a set and an add, and never carry replicated chains #4332
History listings (getHistory, getHistoryOfRecord, read_audit_log) carry an image from patch to patch through HistoryReader (#3504). They are meant to return what the plain rebuild (entry.getValue(store, true, time)) returns, but two of their carry rules disagree with it.
A numeric string set before an add.historyCanCarry accepts any patch whose operations are known, but a later add changes how the plain rebuild types an earlier value. Its reverse walk subtracts the add and returns a number. Reproduced on main:
awaitT.put({id: 'a',n: '5',name: 'base'});awaitT.patch('a',{name: 'first'});awaitT.patch('a',{n: '10'});awaitT.patch('a',{n: {__op__: 'add',value: 1}});awaitT.patch('a',{name: 'last'});// plain rebuild of the third entry: { n: 10, name: 'first' }// getHistory() and getHistoryOfRecord('a'): { n: '10', name: 'first' }
The listing returns the string that was written; the plain rebuild returns the number its reversal produces. Either may be the right answer, but the two paths should agree.
Replicated chains never carry.HistoryReader.read follows a patch from the previous image only when (entry.previousNodeId ?? 0) === image.origin. previousNodeId is never encoded (see the comment in resources/Table.ts above const headNodeId), so the check passes only for origin 0. A record written by another node rebuilds every patch from its current version, which makes listings quadratic again for replicated data.
The subscription replay reader added for #3032 (ReplayReader) handles both cases differently. It carries only chains whose patches set fields (historyCanCarry's plainOnly), and it follows when entry.nodeId matches the image's origin. Moving the listing reader onto the same rules, or sharing one carry implementation between the two, removes both gaps along with the duplicated logic.
Activity