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 full-size 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 full-size slide

  3. one
    Motivation

    View full-size slide

  4. one
    Or, we are doing it ALL wrong

    View full-size slide

  5. Surely
    This is a Joke

    View full-size slide

  6. TIME IS A THING

    View full-size slide

  7. platform test

    View full-size slide

  8. LANGUAGE WARS ARE PASSE

    View full-size slide

  9. CLOSED WORLD ASSUMPTIONS

    View full-size slide

  10. Dependencies
    Cost Too Much

    View full-size slide

  11. eminence
    boxer
    napoleon
    snowball

    View full-size slide

  12. napoleon
    boxer snowball
    eminence wai
    base

    View full-size slide

  13. napoleon
    boxer snowball
    eminence wai
    base
    postgres

    View full-size slide

  14. napoleon
    boxer snowball
    eminence wai
    base
    postgres
    libpq
    OS

    View full-size slide

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

    View full-size slide

  16. annex is a
    fact store

    View full-size slide

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

    View full-size slide

  18. boxer
    a family

    View full-size slide

  19. family/123-abc-456
    a family

    View full-size slide

  20. boxer 1.2.1
    an atom

    View full-size slide

  21. atom/123-abc-456
    an atom

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  25. We ascribe FACTS to ATOMS

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  30. Worlds Change Over Time

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  33. @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 full-size slide

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

    View full-size slide

  35. annex is a
    data store

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  42. annex is a
    language

    View full-size slide

  43. :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 full-size slide

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

    View full-size slide

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

    View full-size slide

  46. First Class Notion of Time

    View full-size slide

  47. :boxer
    :has :feature “multi-part-put”
    :has :commit “abcd-1345”
    :has :branch “master”
    !
    :snowball
    :is :compatable-with atom/…
    !
    :napoleon
    :semver >= 1.3 < 1.4
    !
    +annex.example.com@v12345

    View full-size slide

  48. :boxer
    :has :feature “multi-part-put”
    :has :commit “abcd-1345”
    :has :branch “master”
    !
    :snowball
    :is :compatable-with atom/…
    !
    :napoleon
    :semver >= 1.3 < 1.4
    +annex.internal.com@v123

    View full-size slide

  49. Queries Across Time

    View full-size slide

  50. :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 +annex.example.com@HEAD

    View full-size slide

  51. :no-cve +annex.example.com@HEAD
    assumes irrefutable facts

    View full-size slide

  52. annex is a
    tool

    View full-size slide

  53. annex fetch boxer.ax +server@v123

    View full-size slide

  54. annex fetch +server@v123

    View full-size slide

  55. annex fetch -u +server@v123

    View full-size slide

  56. +server@v123
    .stable.ax:

    View full-size slide

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

    View full-size slide

  58. annex fetch +repository@v123
    annex fetch +repository@v678
    annex fetch +repository@v123
    Instant By Design

    View full-size slide

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

    View full-size slide

  60. annex fact atom/12…ef feature red

    View full-size slide

  61. 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 full-size slide

  62. Usability #6
    Leverage tools already in use

    View full-size slide

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

    View full-size slide

  64. three
    A Deeper Look

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  70. !
    development

    View full-size slide

  71. Time-Dependent Resolution

    View full-size slide

  72. eminence
    boxer
    napoleon
    snowball

    View full-size slide

  73. napoleon.ax:
    :boxer
    :has :feature ingestion
    !
    :snowball
    :has :feature timeline
    .stable.ax:
    +annex.mth.io@v123

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  76. An Open World

    View full-size slide

  77. eminence
    boxer
    napoleon
    snowball

    View full-size slide

  78. eminence
    boxer
    napoleon
    snowball
    _.js
    wai

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  82. Source Substitution

    View full-size slide

  83. eminence
    boxer
    napoleon
    snowball

    View full-size slide

  84. eminence
    boxer
    napoleon
    snowball
    Working On
    A Feature

    View full-size slide

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

    View full-size slide

  86. eminence
    boxer
    napoleon
    snowball
    Need A
    Bug Fix

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  92. eminence
    boxer
    napoleon
    snowball
    Ship It

    View full-size slide

  93. eminence
    boxer
    napoleon
    snowball
    Never had to touch
    intermediates

    View full-size slide

  94. Binary Substitution

    View full-size slide

  95. Requires deduction of output
    signature BEFORE it is built

    View full-size slide

  96. eminence
    boxer
    napoleon
    snowball
    Depends On
    Transitives

    View full-size slide

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

    View full-size slide

  98. !
    distribution

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  102. +red@v123
    Time Axis Is
    Localized To
    A Given Store

    View full-size slide

  103. Immutability Gives Us ∞ Read Replicas
    +red@v123
    red green blue

    View full-size slide

  104. Query Controlled Writes
    red green blue
    +red@v123 => +red@v124

    View full-size slide

  105. Working on a model of facts that
    always commutes

    View full-size slide

  106. Authenticated
    FAMILY and ATOM owners

    View full-size slide

  107. Signed Facts

    View full-size slide

  108. Mediation and Fact Views

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  111. Main challenge is mapping fact
    model to equation

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  114. Reproducibility of solver
    (a cover up)

    View full-size slide

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

    View full-size slide

  116. four
    A Look Forward

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  121. Fixing ALL the COMPILERS

    View full-size slide

  122. Easier extension via
    deductive rules

    View full-size slide

  123. Commutative fact model and
    non-linear versioning

    View full-size slide

  124. these ideas
    STEAL

    View full-size slide

  125. end transmission.

    View full-size slide

  126. towards
    annɛx
    @markhibberd

    View full-size slide

  127. 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 full-size slide