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

Towards "annex", a Fact Based Dependency System (ICFP)

Mark Hibberd
September 06, 2014

Towards "annex", a Fact Based Dependency System (ICFP)

Knowledge is not static. Yet when dealing with program artifacts, we choose to seal off what we know at the point in time when we know the least. This is wrong.

Context is important. Yet when defining dependencies on artifacts, instead of directly specify the query we want (and hence embedding its context), we manually translate our request into antiquated notions of meta-data, encoded as a number, embedded in a string. Yes, semantic versioning is wrong.

Reproducibility is essential. Yet most existing dependency systems force a trade off of rigour and reproducibility against flexibility and ease of use. This is not necessary.

Drawing on well understood foundations from datalog and deductive databases, and utilizing functional programming fundamentals, "annex" takes a different view on how to manage artifacts. We should be able to ask: "Give me the latest binary compatible versions of X with no known CVE"; or, "Give me the last stable builds of my dependencies that have been tested in IE 9, Chrome and Firefox"; or in a more general context outside of dependency resolution, queries such as "What platforms has build x of my library been tested on?" provide a useful understanding of the current state of artifacts; and finally, it should be possible to phrase all of these questions with a first class notion of time, for example "Give me the same dependencies when I last asked this query".

This talk will start by walking through the concepts behind "annex", before taking a deeper look at the design and implementation (in Haskell). We will look at how its functional underpinnings give rise to very desirable properties for a cross-language dependency system. These properties include: trivial distribution and caching; guaranteed reproducibility with minimal context; predictable performance; and interestingly, how steadfastly holding to functional programming principles contributes to being able to deliver a humane user experience in the face of complexity.

Mark Hibberd

September 06, 2014
Tweet

More Decks by Mark Hibberd

Other Decks in Programming

Transcript

  1. towards
    annɛx
    @markhibberd

    View Slide

  2. “The enemy is the gramophone
    mind, whether or not one
    agrees with the record that is
    being played at the moment.”
    George Orwell - The Freedom of the Press

    View Slide

  3. one
    Motivation

    View Slide

  4. one
    Or, we are doing it ALL wrong

    View Slide

  5. 2.1.3

    View Slide

  6. Surely
    This is a Joke

    View Slide

  7. TIME IS A THING

    View Slide

  8. commit

    View Slide

  9. ci

    View Slide

  10. publish

    View Slide

  11. platform test

    View Slide

  12. production

    View Slide

  13. performance

    View Slide

  14. cve

    View Slide

  15. LANGUAGE WARS ARE PASSE

    View Slide

  16. CLOSED WORLD ASSUMPTIONS

    View Slide

  17. Dependencies
    Cost Too Much

    View Slide

  18. two
    Concepts

    View Slide

  19. eminence
    boxer
    napoleon
    snowball

    View Slide

  20. napoleon
    boxer snowball
    eminence wai
    base

    View Slide

  21. napoleon
    boxer snowball
    eminence wai
    base
    postgres

    View Slide

  22. napoleon
    boxer snowball
    eminence wai
    base
    postgres
    libpq
    OS

    View Slide

  23. napoleon
    boxer snowball
    eminence wai
    base
    postgres
    libpq
    OS
    CLANG

    View Slide

  24. annex is a
    fact store

    View Slide

  25. START WITH SOMETHING WE
    HAVE (OR CAN GET)

    View Slide

  26. boxer
    a family

    View Slide

  27. family/123-abc-456
    a family

    View Slide

  28. boxer 1.2.1
    an atom

    View Slide

  29. atom/123-abc-456
    an atom

    View Slide

  30. a fact
    fact/123-abc-457:
    commit: bd2f074…02

    View Slide

  31. fact/123-abc-458:
    api-signature: […]
    a fact

    View Slide

  32. fact/123-abc-459:
    feature: it-works
    a fact

    View Slide

  33. We ascribe FACTS to ATOMS

    View Slide

  34. atom/123-abc-456
    fact/123-abc-457
    fact/123-abc-458
    fact/123-abc-459

    View Slide

  35. boxer 1.2.1
    commit: bd2f074…02
    api-signature: […]
    feature: it-works

    View Slide

  36. The view of FACTS against ATOMS
    at a point in TIME is a WORLD

    View Slide

  37. boxer
    facts/…
    snowball
    facts/…
    napoleon
    facts/…
    a single world

    View Slide

  38. Worlds Change Over Time

    View Slide

  39. @v1
    boxer 1.2.1
    commit: bd2f074…02
    api-signature: […]
    feature: it-works

    View Slide

  40. fact/123-abc-460:
    tested: FreeBSD-9.1

    View Slide

  41. @v1
    boxer 1.2.1
    commit: bd2f074…02
    api-signature: […]
    feature: it-works
    @v2
    boxer 1.2.1
    commit: bd2f074…02
    api-signature: […]
    feature: it-works
    tested: FreeBSD-9.1

    View Slide

  42. Usability #1
    Design desisions should be
    framed in terms of
    predictability and repeatability

    View Slide

  43. annex is a
    data store

    View Slide

  44. Because we believe in
    interacting with an open world
    doesn’t mean we have to trust it.

    View Slide

  45. atom/123-abc-456
    fact/123-abc-457
    fact/123-abc-458
    fact/123-abc-459
    artifact/123-abc-459

    View Slide

  46. boxer 1.2.1
    commit: bd2f074…02
    api-signature: […]
    feature: it-works
    artifact:
    tag: bin/boxer
    flags: […]
    address: e2f1…bc74

    View Slide

  47. points to
    annex/storage/e2f1…bc74/data
    /info
    boxer 1.2.1
    artifact:
    tag: bin/boxer
    flags: […]
    address: e2f1…bc74

    View Slide

  48. annex/storage/e2f1…bc74/data
    /info
    local/storage/e2f1…bc74/data
    /info
    free predictable caching

    View Slide

  49. Usability #2
    Never download something
    already on a users machine

    View Slide

  50. annex is a
    language

    View Slide

  51. :boxer
    :has :feature “multi-part-put”
    :has :commit “abcd-1345”
    :has :branch “master”
    !
    :snowball
    :is :compatable-with atom/…
    !
    :napoleon
    :semver >= 1.3 < 1.4
    !

    View Slide

  52. Usability #3
    Precision is important, users
    should only have to specify
    what is important to them

    View Slide

  53. Usability #4
    Flexibility must never come
    at the cost of determinism

    View Slide

  54. First Class Notion of Time

    View Slide

  55. :boxer
    :has :feature “multi-part-put”
    :has :commit “abcd-1345”
    :has :branch “master”
    !
    :snowball
    :is :compatable-with atom/…
    !
    :napoleon
    :semver >= 1.3 < 1.4
    !
    [email protected]

    View Slide

  56. :boxer
    :has :feature “multi-part-put”
    :has :commit “abcd-1345”
    :has :branch “master”
    !
    :snowball
    :is :compatable-with atom/…
    !
    :napoleon
    :semver >= 1.3 < 1.4
    [email protected]

    View Slide

  57. Queries Across Time

    View Slide

  58. :boxer
    :has :feature “multi-part-put”
    :has :commit “abcd-1345”
    :has :branch “master”
    !
    :snowball
    :is :compatable-with atom/…
    !
    :napoleon
    :semver >= 1.3 < 1.4
    :no-cve [email protected]

    View Slide

  59. :no-cve [email protected]
    assumes irrefutable facts

    View Slide

  60. annex is a
    tool

    View Slide

  61. annex fetch boxer.ax [email protected]

    View Slide

  62. annex fetch [email protected]

    View Slide

  63. annex fetch -u [email protected]

    View Slide

  64. [email protected]
    .stable.ax:

    View Slide

  65. annex fetch

    View Slide

  66. Usability #5
    Don’t generate files that a
    user wouldn’t write by hand

    View Slide

  67. annex fetch [email protected]
    annex fetch [email protected]
    annex fetch [email protected]
    Instant By Design

    View Slide

  68. annex atom --create family/1d…3b

    View Slide

  69. annex fact atom/12…ef feature red

    View Slide

  70. git checkout -b topic/feature
    git add src/Boxer.hs
    git commit -m ‘Great change!’
    git notes add --ref=annex \
    -m “:feature win” HEAD
    git push origin topic/feature
    git push origin refs/notes/*
    annex fact atom/12…ef --git HEAD

    View Slide

  71. Usability #6
    Leverage tools already in use

    View Slide

  72. Usability #7
    Don’t be as bad as Git

    View Slide

  73. three
    A Deeper Look

    View Slide

  74. !
    resolution

    View Slide

  75. annex.mth.io
    github.com/ambiata/boxer
    Resolution

    View Slide

  76. annex.mth.io
    github.com/ambiata/boxer
    Retrieve Facts
    Resolution

    View Slide

  77. annex.mth.io
    github.com/ambiata/boxer
    Retrieve Facts
    Resolution

    View Slide

  78. annex.mth.io
    github.com/ambiata/boxer
    Send Query
    Resolution

    View Slide

  79. annex.mth.io
    github.com/ambiata/boxer
    Synchronize Artifacts
    Resolution

    View Slide

  80. !
    development

    View Slide

  81. Time-Dependent Resolution

    View Slide

  82. eminence
    boxer
    napoleon
    snowball

    View Slide

  83. napoleon.ax:
    :boxer
    :has :feature ingestion
    !
    :snowball
    :has :feature timeline
    .stable.ax:
    [email protected]

    View Slide

  84. [ci] stable
    [ci] stable
    annex fetch @HEAD
    annex fetch

    View Slide

  85. View Slide

  86. Usability #8
    Design for simulation,
    notifications and metrics

    View Slide

  87. An Open World

    View Slide

  88. eminence
    boxer
    napoleon
    snowball

    View Slide

  89. eminence
    boxer
    napoleon
    snowball
    _.js
    wai

    View Slide

  90. napoleon.ax:
    :wai
    :source hackage
    :semver == 2.1.*
    :underscore.js
    :source cdnjs
    :semver == 1.*

    View Slide

  91. napoleon.ax:
    :wai
    :source hackage
    :semver == 2.1.*
    :underscore.js
    :source cdnjs
    :semver == 1.*
    :tested-on ie4

    View Slide

  92. Usability #9
    Start with the premise that
    you need to interact with
    less principled systems

    View Slide

  93. Source Substitution

    View Slide

  94. eminence
    boxer
    napoleon
    snowball

    View Slide

  95. eminence
    boxer
    napoleon
    snowball
    Working On
    A Feature

    View Slide

  96. napoleon.ax:
    :boxer
    :has :feature ingestion
    !
    :snowball
    :has :feature timeline
    !
    !
    !

    View Slide

  97. eminence
    boxer
    napoleon
    snowball
    Need A
    Bug Fix

    View Slide

  98. annex fetch --source-substitute \
    eminence ../eminence

    View Slide

  99. annex fetch --source-substitute \
    eminence ../eminence\
    --ignore-constraints

    View Slide

  100. :boxer
    :has :feature ingestion
    !
    :snowball
    :has :feature timeline
    !
    :eminence
    :has :commit ab34…f3e1
    :transitive
    napoleon.ax:

    View Slide

  101. annex fact git/HEAD fix ‘#112’

    View Slide

  102. :boxer
    :has :feature ingestion
    !
    :snowball
    :has :feature timeline
    !
    :eminence
    :has :fix #112
    :transitive
    napoleon.ax:

    View Slide

  103. eminence
    boxer
    napoleon
    snowball
    Ship It

    View Slide

  104. eminence
    boxer
    napoleon
    snowball
    Never had to touch
    intermediates

    View Slide

  105. Binary Substitution

    View Slide

  106. Requires deduction of output
    signature BEFORE it is built

    View Slide

  107. eminence
    boxer
    napoleon
    snowball
    Depends On
    Transitives

    View Slide

  108. Nix Style Build The World +
    Better Language Support
    Essential

    View Slide

  109. !
    distribution

    View Slide

  110. If we assume open world,
    multiple annex fact stores
    is reality

    View Slide

  111. Handling time is non-trivial
    in a distributed system

    View Slide

  112. Annex (currently) chooses
    federation over being a truly
    distributed system

    View Slide

  113. [email protected]
    Time Axis Is
    Localized To
    A Given Store

    View Slide

  114. Immutability Gives Us ∞ Read Replicas
    [email protected]
    red green blue

    View Slide

  115. Query Controlled Writes
    red green blue
    [email protected] => [email protected]

    View Slide

  116. Working on a model of facts that
    always commutes

    View Slide

  117. !
    trust

    View Slide

  118. Authenticated
    FAMILY and ATOM owners

    View Slide

  119. Signed Facts

    View Slide

  120. Mediation and Fact Views

    View Slide

  121. annex.mth.io
    github.com/ambiata/boxer
    Fact Mediation
    annex.inside.ambiata.com
    [signed-by:…]
    [owned-by:…]

    View Slide

  122. !
    solving

    View Slide

  123. DPLL / SAT based solution w/
    inspiration from OPIUM paper

    View Slide

  124. Main challenge is mapping fact
    model to equation

    View Slide

  125. Main challenge in mapping fact
    model is deducing identity from
    user specified query

    View Slide

  126. Secondary challenge is caching
    partial solutions and reducing
    duplicated work where possible

    View Slide

  127. Reproducibility of solver
    (a cover up)

    View Slide

  128. :boxer
    :has :feature ingestion
    !
    :snowball
    :has :feature timeline
    !
    :annex-resolver
    :has :version 1
    napoleon.ax:

    View Slide

  129. four
    A Look Forward

    View Slide

  130. 0
    25
    50
    75
    100
    April May June July
    Deeper Analytics

    View Slide

  131. 0
    25
    50
    75
    100
    April May June July
    Deeper Analytics
    arbitrary queries
    and reporting
    over atoms

    View Slide

  132. 0
    25
    50
    75
    100
    April May June July
    Deeper Analytics
    inference of
    relevant facts
    for customer issues

    View Slide

  133. 0
    25
    50
    75
    100
    April May June July
    Deeper Analytics
    predict failure
    in advance

    View Slide

  134. Fixing ALL the COMPILERS

    View Slide

  135. Easier extension via
    deductive rules

    View Slide

  136. Commutative fact model and
    non-linear versioning

    View Slide

  137. these ideas
    STEAL

    View Slide

  138. end transmission.

    View Slide

  139. towards
    annɛx
    @markhibberd

    View Slide

  140. Images
    !
    Unmodified, Licences Specified at WikiMedia links"
    http://commons.wikimedia.org/wiki/File:Clock_Gare_de_Paris-Est.jpg!
    http://en.wikipedia.org/wiki/File:Bundesarchiv_Bild_101III-
    Merz-014-12A,_Russland,_Beginn_Unternehmen_Zitadelle,_Panzer.jpg!
    http://commons.wikimedia.org/wiki/File:French_-_Door_with_Cat_Hole_-
    _Walters_64164.jpg!
    !
    Unmodified. CC BY 2.0 (https://creativecommons.org/licenses/by/2.0/)"
    https://www.flickr.com/photos/timothymorgan/75288582/!
    https://www.flickr.com/photos/timothymorgan/75288583/!
    https://www.flickr.com/photos/timothymorgan/75294154/!
    https://www.flickr.com/photos/timothymorgan/75593155/!
    https://www.flickr.com/photos/timothymorgan/75593155/

    View Slide