PolymerLabs / arcs

Arcs
BSD 3-Clause "New" or "Revised" License
58 stars 35 forks source link

Time-Travel Tool for Arcs #2609

Open piotrswigon opened 5 years ago

piotrswigon commented 5 years ago

Core observation: We're not far away from performing time-travel on particles. One obvious use case is debugging particles through replaying the exact session that occurred. i.e. Developer clicks around, they see something is wrong. They have a hypothesis, so they set up some breakpoints and perform a replay of the session inspect what was happening inside particles.

What we need: Refactoring a few APIs to become oracles controlled by Particle Execution Host: XHRs, setTimeout, APIs for receiving time and a random number generator?

How do we do that: Particles Execution Context can be re-created with exactly the same messages being replayed to it. Particles should in principle perform the same requests once booted (i.e. they should be deterministic). If they are not - we should figure out why.

Caveat: We cannot really time travel backwards, unless PEC becomes in control of the internal state of particles (That seems to be the same as enforcing reactive programming model, which is being discussed). But we can wipe everything and reboot the PEC and replay messages, which is functionally equivalent to time travel.

shaper commented 5 years ago

@cromwellian would be interested in this as he played with the Redux time travel tool while working on the Cloud PWA.