<commit_before>Architecture Overview
=====

Dynajot works by tracking changes in the dom (from [js/change.js](js.change.js)), sending those changes to other browsers, maintaining a copy of the state on the server, and maintaining a total ordering of all the cahnges that occurred (so different clients always converge on the same state, even if they got changes in the "wrong" order).

The path that a change takes from being created in one browser to being applied in another is:

1. `change.changes` detects a change (via `mutation.onChange`), and produces a delta
2. That delta gets passed to a callback in `sync.sync` (`sync` is our only export, it's `dynajot` in the build)
3. `sync.sync` assigns it a message id with `ids.message_id` (this is globally unique, and used for ordering)
4. `timeline.addDelta` gets passed the delta, and adds it to the timeline so we can re-apply it if something comes in before it (in logical time) lataer (in wall time)
5. `conn.send` sends it over the websocket to the server
6. `parrot.ParrotHandler.on_message` receives the message off the websocket
7. `ParrotHandler` adds the delta to its `patch.Document` (which changes the initial state that new connections get sent)
8. `ParrotHandler` broadcasts the delta out to all of the other websocket connections for that document
9. The delta appears in a callback in `sync.sync` (line 178 at the time of this writing)
10. The delta gets passed to `timeline.changeset`, which looks for any deltas that occur after it in logical time and merges them together (in order) to produce one delta per dom node
11. Those deltas are passed to `enact.appliesDeltas`, which performs the dom changes needed to reflect the delta in the dom<commit_msg>Update arch.md<commit_after>Architecture Overview
=====

Dynajot works by tracking changes in the dom (from [js/change.js](js.change.js)), sending those changes to other browsers, maintaining a copy of the state on the server, and maintaining a total ordering of all the changes that occurred (so different clients always converge on the same state, even if they got changes in the "wrong" order).

The path that a change takes from being created in one browser to being applied in another is:

1. `change.changes` detects a change (via `mutation.onChange`), and produces a delta
2. That delta gets passed to a callback in `sync.sync` (`sync` is our only export, it's `dynajot` in the build)
3. `sync.sync` assigns it a message id with `ids.message_id` (this is globally unique, and used for ordering)
4. `timeline.addDelta` gets passed the delta, and adds it to the timeline so we can re-apply it if something comes in before it (in logical time) lataer (in wall time)
5. `conn.send` sends it over the websocket to the server
6. `parrot.ParrotHandler.on_message` receives the message off the websocket
7. `ParrotHandler` adds the delta to its `patch.Document` (which changes the initial state that new connections get sent)
8. `ParrotHandler` broadcasts the delta out to all of the other websocket connections for that document
9. The delta appears in a callback in `sync.sync` (line 178 at the time of this writing)
10. The delta gets passed to `timeline.changeset`, which looks for any deltas that occur after it in logical time and merges them together (in order) to produce one delta per dom node
11. Those deltas are passed to `enact.appliesDeltas`, which performs the dom changes needed to reflect the delta in the dom
{'fraction_non_alphanumeric': 0.06291678747463032, 'fraction_numerical': 0.009278051609162076, 'mean_word_length': 4.609756097560975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3541106', 'n_tokens_mistral': 939, 'n_tokens_neox': 902, 'n_words': 546}