Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Graphel: The Meaning of an Immutable World

Graphel: The Meaning of an Immutable World

A conceptual introduction to approaching virtual interaction as human-machine conversations modeled on persistent data-structures using Clojure and Datomic and its benefits, possibilities and long-term implications.

Michiel Trimpe

July 03, 2014
Tweet

More Decks by Michiel Trimpe

Other Decks in Programming

Transcript

  1. Event Sourcing • Widely recognized as A Good Thing •

    Lambda Architecture, Kafka, Datomic • Especially for purely functional data • But how do we work with it in practice?
  2. Inspiration Is there anything we're already used to that: •

    Coordinates interaction between entities • Consists of a sequence of events • Can't be altered once it's recorded
  3. Speech Acts • A conversation is a sequence of speech

    acts • A speech act is inherently immutable • We already use it to create our social world • Well suited to modeling information exchange
  4. Example: Landing Page Hello! We sell widgets. Do you want

    to order now or read more? I would like to read some more please. We have widgets from A to Z. John and Mary also think it's good. What did Mary say about it? She said "They're great. Cheap, fast and good!" Should we perhaps call you for some personal advice on widgets? Yeah sure. Great? What's your name and phone number?
  5. Example: Admin UI These are the 50 most recently added

    widgets: .... You can add one, see the next 50 or pick one you want to change. I would like to change that one We currently have ... on file. Do you want to change price, name or stock, or forget about it for now. I want to give it a different price. What price do you want to give it? €29,95 12:47:59 at 13 Nov 2014 12:48:34 at 13 Nov 2014 12:48:34 at 13 Nov 2014 12:48:46 at 13 Nov 2014 12:48:46 at 13 Nov 2014 12:48:58 at 13 Nov 2014
  6. Example: Admin UI These are the 50 most recently added

    widgets: .... You can add one, see the next 50 or pick one you want to change. I would like to change that one We currently have ... on file. Do you want to change price, name or stock, or forget about it for now. I want to give it a different price. What price do you want to give it? €29,95 12:47:59 at 13 Nov 2014 12:48:34 at 13 Nov 2014 12:48:34 at 13 Nov 2014 12:48:46 at 13 Nov 2014 12:48:46 at 13 Nov 2014 12:48:58 at 13 Nov 2014 Datomic Transactions
  7. Speech Act Generator • Speech acts are communication devices that:

    • transfer a model of the world • narrow behavior to meaningful responses • Every user interface is a speech act • Every input lets users perform speech acts System are just speech act generators
  8. Performing Acts • Acts are inherently performative • We need

    give those acts the best stage • Create dedicated interfaces for types of acts • Optimising for another kind of performance • Designing for muscle-memory responses • Auto-cueing teleprompter for video recordings
  9. Human Perspective As a speech act generator you are in

    the middle of a conversation and will decide what to say next based on everything you already know and that has been said until now. Sounds familiar?
  10. Drawbacks Even when all inputs are immutably the generator still

    depends on the entire VM, meaning they: • always have to live server side • aren't referentially transparent • must store raw output data for history (At least until EClj performantly support first class namespaces.)
  11. The Problem We want to • embed complex, conditional, layered

    interactions • into a purely functional data structure • with minimal amounts of purely referential code allowing others to locally anticipate actions.
  12. State of the Art • Scripts & Forms • Describe

    a sequence of events • Branching/skipping based on responses • Emails • Free form pseudo-code description of anything
  13. The Essence We want to handle a sequence of events

    and based on the received event and previous actions choose from a number of pre-determined actions
  14. State Machines • Easily understood and represented visually • Works

    on the level of granularity of speech acts • Datomic can store it as a persistent data structure • Allows responses to refer to a specific state/act • States are good place for limited, versioned, logic
  15. The Un/Redo Model Given a sequence with full event history

    • Undo moves current pointer back in the sequence • Redo moves the pointer forward • Actions 'sideline' acts beyond current pointer • Optionally rolling back their side effects • Or just create a new version of the current act
  16. Layered Hierarchies Flat state machines quickly become unwieldy. You can

    handle that by nesting state machines, where each state can be it's own state machine, allowing for a high degree of composability. (If you squint you can even see objects there ;)
  17. Neurology We humans have a single focus which can: •

    switch between contexts • nest contexts inside other contexts • maintain state (fuzzy history) per context • narrow action, and perception, through context
  18. States and Transitions • Each path in a website is

    a state • Path fragments refer to hierarchical levels /inbox/12/my-thread/73/third-response#reply-to-all • Clicking a link (GET) is argument-less transition • Submitting a form (POST) an argumented transition • With redirects leading to a new state
  19. HATEOAS built in • The difficulty of HATEOAS lies in

    discoverability • We can have tons of speech act types
 Yes/No, Multiple Choice, Forms, Video, Audio, Drawings, 
 Payments, Social Shares, GPS, Weight • But each act type has just a few well-defined exits • Making discoverability not just feasible, but built in
  20. Multi Service Support • States are defined as write-once, read-many

    acts • Any service can offer those same guarantees • Enabling iFrame-based third party act types • Even with seamless authentication using OAuth
  21. History as a Sequence • The browser history is the

    event history • Clicking back is undo; forward redo. • Same for scrolling past sections/paragraphs • A vertically arranged sequence of acts
  22. Mobile • Focused speech act UIs work well full screen

    • History support through a rewind gesture or • Swiping across a visual "sequence of acts" • Automatically accommodates all aspect ratios • Nested contexts as hide-on-scroll navigation bars • Multi service with intents or protocol ping-pong
  23. Notifications Lock Screens, Watches, Glass • Key information can be

    summarized • Simple response actions performed inline • Single click resumes full operational state • Voice recognition with restricted vocabulary
  24. Cross Device • Traditionally syncing across devices is hard •

    Live Datalog queries on Datomic make it possible • Offline viewing can be built in through e.g. Datascript • Offline speculative operation possible through analysis: • Conflict-free work through continuity of user memory • Informed speculative work on branch prediction • Natural conflict resolution schemes either way
  25. Business • Your interactions all have certain (shared) goals
 Persuading

    people, Collecting profiles, Losing weight • Your success depends on your ability to help your customers achieve their goals • You have access to a complete view on all of your customer interactions So what do you do?
  26. Going Meta • Query the collection of all your interactions

    • Identify areas of improvement
 Lost customers, Plateauing users, Losing engagement • Design (experimental) corrective action • Select affected customers and apply the action • Automate the process if it ends up working
  27. A Sense of History Repeatability is key for a successful

    experiment. Luckily, as long as we can display stored acts, especially if they contain the creation process, we can re-experience the entire user journey and create transcripts/re-presentations from them.
  28. Stay In Your Flow We want to change interactions with

    users in them, which used to be a prohibitively hard problem. But it comes completely for free if we • store state machine definitions in Datomic • assign users to specific versions of them • store the code used for branching
  29. One Step At a Time We run experiments to learn

    from them so we want only a single variable to change. Single-act interfaces are great experimental units. The sequence approach perfectly isolates them, making it the perfect platform for A/B testing (or any other type of sociological research.)
  30. Machine Learning Classical A/B testing is about teaching people things.

    What if you care more about results than wisdom? Let the machine do the learning! Multi-armed bandit can optimise for you, automatically choosing versions giving best results
  31. Deploying Experiments Isn't every deployment an experiment? Just deploy new

    versions of (inter)act(ion)s and migrate to them at your leisure or even have a multi-armed-bandit automagically phase out bad deploys
  32. Learning Intelligence "When using such a generator you are in

    the middle of a conversation and will decide what to say next based on everything you already know and that has happened until now."
  33. The act generator is the perfect foundation for bootstrapping machine

    intelligence that works the same way humans do: through interacting and experimenting; but in a controlled, limited, fashion... Learning Intelligence
  34. NSA-proofing • So far we assumed everything runs on a

    server • That means the NSA is, or can be, watching • People will never speak freely if that’s the case • Nor will companies share all their data with you
  35. To Each Their Own • Each participant can control their

    own data • And reference data used from other participants State machine definitions. Branching logic. User acts. • Everyone gets a namespaced Datomic-style DB • Work with live/pub-sub Datalog cross-DB querying • Based on a.o. Nikitonsky’s Datomic as a Protocol
  36. On A Need-to-Know Basis • Encrypt and sign all your

    data with a personal key • Share by encrypting with others' public signatures • Share data, by context, on a need-to-know basis • Have privacy correspond to cryptographical reality.
  37. Signed, Identity • Identities are defined by serialization • People

    can (temporarily) assume an identity • Sign everything you created under that identity • Retroactively revokable when compromised • Publish publicly for a timestamped proof • Enabling e.g. secure ad-hoc referendum voting
  38. A New Paradigm • Using materialized views on persistent databases

    • You can create a view of all public information • Including aggregations of private data • And similar views of accessible data per recipient • And encrypt those materialised views accordingly
  39. A New Paradigm Laying the foundation for a computing paradigm

    in which you can communicate securely and subscribe to, download and query every piece of data you have access to and not a single thing more.