<commit_before>
require('proof')(6, prove)

function prove (assert) {
    var Legislator = require('../../legislator'),
        Network = require('../../synchronous/network'),
        Machine = require('../../synchronous/machine')

    var legislators = [ new Legislator(0) ]
    legislators[0].bootstrap()

    function logger (count, id, message) {
        console.log(count, id, message)
    }

    var network = new Network
    var machine = new Machine(network, legislators[0], logger)
    network.machines.push(machine)

    // Legislator.synchronous(legislators, 0, logger)

    network.tick()

    assert(legislators[0].government, {
        id: '1/0', leader: 0, majority: [ 0 ], members: [ 0 ], interim: false
    }, 'bootstrap')

    network.machines.push(new Machine(network, new Legislator(1), logger))

    network.machines[1].legislator.sync([ 0 ], 20)
    network.tick()

    assert(network.machines[1].legislator.government, {
        id: '1/0', leader: 0, majority: [ 0 ], members: [ 0 ], interim: false
    }, 'synchronize join')

    // todo: yes, you look inside the response. it is not opaque. you are at
    // this low level when you are trying to create an interface to an algorithm
    // that is uncommon and subtle.
    var cookie = network.machines[1].legislator.naturalize()
    assert(cookie, 1, 'cookie')
    network.tick()

    assert(legislators[0].government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'grow')

    assert(network.machines[1].legislator.government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'cleanup pulse')

    network.machines.push(new Machine(network, new Legislator(2), logger))
    network.machines[2].legislator.sync([ 0 ], 20)
    network.tick()

    assert(network.machines[2].legislator.government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'cleanup pulse')

    network.machines[2].legislator.naturalize()
    network.tick()

    assert(network.machines[1].legislator.government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'cleanup pulse')
}
<commit_msg>Create a three member parliament.<commit_after>
require('proof')(7, prove)

function prove (assert) {
    var Legislator = require('../../legislator'),
        Network = require('../../synchronous/network'),
        Machine = require('../../synchronous/machine')

    var legislators = [ new Legislator(0) ]
    legislators[0].bootstrap()

    function logger (count, id, message) {
        console.log(count, id, message)
    }

    var network = new Network
    var machine = new Machine(network, legislators[0], logger)
    network.machines.push(machine)

    // Legislator.synchronous(legislators, 0, logger)

    network.tick()

    assert(legislators[0].government, {
        id: '1/0', leader: 0, majority: [ 0 ], members: [ 0 ], interim: false
    }, 'bootstrap')

    network.machines.push(new Machine(network, new Legislator(1), logger))

    network.machines[1].legislator.sync([ 0 ], 20)
    network.tick()

    assert(network.machines[1].legislator.government, {
        id: '1/0', leader: 0, majority: [ 0 ], members: [ 0 ], interim: false
    }, 'synchronize join')

    // todo: yes, you look inside the response. it is not opaque. you are at
    // this low level when you are trying to create an interface to an algorithm
    // that is uncommon and subtle.
    var cookie = network.machines[1].legislator.naturalize()
    assert(cookie, 1, 'cookie')
    network.tick()

    assert(legislators[0].government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'grow')

    assert(network.machines[1].legislator.government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'cleanup pulse')

    network.machines.push(new Machine(network, new Legislator(2), logger))
    network.machines[2].legislator.sync([ 0 ], 20)
    network.tick()

    assert(network.machines[2].legislator.government, {
        id: '2/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1 ], interim: false
    }, 'cleanup pulse')

    network.machines[2].legislator.naturalize()
    network.tick()

    assert(network.machines[1].legislator.government, {
        id: '3/0', leader: 0, majority: [ 0, 1 ], members: [ 0, 1, 2 ], interim: false
    }, 'cleanup pulse')
}

{'fraction_non_alphanumeric': 0.16005379959650304, 'fraction_numerical': 0.028020623178659495, 'mean_word_length': 3.030713640469738, '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': '884531', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1380, 'n_words': 375}