Browse Source

First commit

Stephen Starkey 1 year ago
commit
2c9a0aaa68
42 changed files with 3276 additions and 0 deletions
  1. 19
    0
      .gitignore
  2. 19
    0
      .travis.yml
  3. 10
    0
      Dockerfile
  4. 661
    0
      LICENSE
  5. 98
    0
      README.md
  6. 8
    0
      fail-if-nonempty
  7. 16
    0
      full-build
  8. 61
    0
      project.clj
  9. 43
    0
      resources/governance.ebnf
  10. 5
    0
      run-with-docker
  11. 470
    0
      spec/freefrog/governance_circles_spec.clj
  12. 287
    0
      spec/freefrog/governance_roles_spec.clj
  13. 56
    0
      spec/freefrog/governance_spec_helpers.clj
  14. 12
    0
      spec/freefrog/lang/basic/001_initial_circle.txt
  15. 20
    0
      spec/freefrog/lang/basic/002_new_roles.txt
  16. 17
    0
      spec/freefrog/lang/basic/003_updating_roles.txt
  17. 7
    0
      spec/freefrog/lang/basic/004_updating_subcircles.txt
  18. 7
    0
      spec/freefrog/lang/basic/005_role_appointments.txt
  19. 26
    0
      spec/freefrog/lang/courage_labs/2015-02-06_adoption.txt
  20. 42
    0
      spec/freefrog/lang/courage_labs/2015-04-15_anchor_circle.txt
  21. 77
    0
      spec/freefrog/lang/courage_labs/2015-04-22_anchor_circle.txt
  22. 11
    0
      spec/freefrog/lang/courage_labs/2015-04-22_software_tools_circle.txt
  23. 2
    0
      spec/freefrog/lang/courage_labs/2015-05-09_anchor_circle.txt
  24. 5
    0
      spec/freefrog/lang/courage_labs/2015-05-10a_software_tools_circle.txt
  25. 8
    0
      spec/freefrog/lang/courage_labs/2015-05-10b_software_tools_circle.txt
  26. 4
    0
      spec/freefrog/lang/courage_labs/2015-05-16_software_tools.txt
  27. 1
    0
      spec/freefrog/lang/courage_labs/2015-06-11_anchor_circle.txt
  28. 12
    0
      spec/freefrog/lang/courage_labs/2015-06-20_anchor_circle.txt
  29. 3
    0
      spec/freefrog/lang/courage_labs/2015-07-23_anchor_circle.txt
  30. 17
    0
      spec/freefrog/lang/courage_labs/2015-07-23_software_tools_circle.txt
  31. 7
    0
      spec/freefrog/lang/courage_labs/2015-10-26_software_tools_circle.txt
  32. 11
    0
      spec/freefrog/lang/courage_labs/2016-01-01_anchor_circle.txt
  33. 10
    0
      spec/freefrog/lang/courage_labs/2016-01-01_partner_membership.txt
  34. 4
    0
      spec/freefrog/lang/multiple-subcircle-governance.txt
  35. 168
    0
      spec/freefrog/lang_spec.clj
  36. 68
    0
      spec/freefrog/render_spec.clj
  37. 112
    0
      src/clj/freefrog/cli.clj
  38. 110
    0
      src/clj/freefrog/core_roles.clj
  39. 443
    0
      src/clj/freefrog/governance.clj
  40. 217
    0
      src/clj/freefrog/lang.clj
  41. 76
    0
      src/clj/freefrog/render.clj
  42. 26
    0
      src/java/freefrog/GovernanceParseException.java

+ 19
- 0
.gitignore View File

@@ -0,0 +1,19 @@
1
+pom.xml
2
+*jar
3
+/lib/
4
+/classes/
5
+/out/
6
+/target/
7
+.lein-deps-sum
8
+.lein-repl-history
9
+.lein-failures
10
+.lein-plugins/
11
+/dev-resources/public/js/*
12
+.idea
13
+.repl
14
+freefrog.iml
15
+.DS_Store
16
+/docs/
17
+.nrepl-port
18
+.floo*
19
+

+ 19
- 0
.travis.yml View File

@@ -0,0 +1,19 @@
1
+language: clojure
2
+jdk: oraclejdk8
3
+script: ./full-build
4
+deploy:
5
+  provider: s3
6
+  access_key_id: AKIAILUSIQQRDIX2UQGQ
7
+  secret_access_key:
8
+    secure: U5h6bonKgx5P3ggMbfnCLctIFsTGgeQdDs+wG0/z0EJXH5lsbjDBN7wOB0BYZzNMphULhL686bHcHbKAMdRk6DnxEvkRg67VzToAToT22aIHrGl3a7wD8i5iBFI2NWEhZCkRVQG0xs9iKhzhdSLVZ5Es5gIKPByFmpFVtFTP1CM=
9
+  bucket: freefrog
10
+  local-dir: docs
11
+  upload-dir: docs
12
+  acl: public_read
13
+  skip_cleanup: true
14
+  on:
15
+    repo: couragelabs/freefrog
16
+sudo: false
17
+cache:
18
+  directories:
19
+  - $HOME/.m2

+ 10
- 0
Dockerfile View File

@@ -0,0 +1,10 @@
1
+FROM dockerfile/java:oracle-java8
2
+MAINTAINER Courage Labs, LLC <tech@couragelabs.com>
3
+
4
+RUN sudo apt-get update
5
+
6
+ADD target/freefrog-0.0.1-SNAPSHOT-standalone.jar /srv/freefrog.jar
7
+
8
+EXPOSE 3000
9
+
10
+CMD ["java", "-server", "-jar", "/srv/freefrog.jar"]

+ 661
- 0
LICENSE View File

@@ -0,0 +1,661 @@
1
+                    GNU AFFERO GENERAL PUBLIC LICENSE
2
+                       Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+                            Preamble
9
+
10
+  The GNU Affero General Public License is a free, copyleft license for
11
+software and other kinds of works, specifically designed to ensure
12
+cooperation with the community in the case of network server software.
13
+
14
+  The licenses for most software and other practical works are designed
15
+to take away your freedom to share and change the works.  By contrast,
16
+our General Public Licenses are intended to guarantee your freedom to
17
+share and change all versions of a program--to make sure it remains free
18
+software for all its users.
19
+
20
+  When we speak of free software, we are referring to freedom, not
21
+price.  Our General Public Licenses are designed to make sure that you
22
+have the freedom to distribute copies of free software (and charge for
23
+them if you wish), that you receive source code or can get it if you
24
+want it, that you can change the software or use pieces of it in new
25
+free programs, and that you know you can do these things.
26
+
27
+  Developers that use our General Public Licenses protect your rights
28
+with two steps: (1) assert copyright on the software, and (2) offer
29
+you this License which gives you legal permission to copy, distribute
30
+and/or modify the software.
31
+
32
+  A secondary benefit of defending all users' freedom is that
33
+improvements made in alternate versions of the program, if they
34
+receive widespread use, become available for other developers to
35
+incorporate.  Many developers of free software are heartened and
36
+encouraged by the resulting cooperation.  However, in the case of
37
+software used on network servers, this result may fail to come about.
38
+The GNU General Public License permits making a modified version and
39
+letting the public access it on a server without ever releasing its
40
+source code to the public.
41
+
42
+  The GNU Affero General Public License is designed specifically to
43
+ensure that, in such cases, the modified source code becomes available
44
+to the community.  It requires the operator of a network server to
45
+provide the source code of the modified version running there to the
46
+users of that server.  Therefore, public use of a modified version, on
47
+a publicly accessible server, gives the public access to the source
48
+code of the modified version.
49
+
50
+  An older license, called the Affero General Public License and
51
+published by Affero, was designed to accomplish similar goals.  This is
52
+a different license, not a version of the Affero GPL, but Affero has
53
+released a new version of the Affero GPL which permits relicensing under
54
+this license.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+                       TERMS AND CONDITIONS
60
+
61
+  0. Definitions.
62
+
63
+  "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+  "Copyright" also means copyright-like laws that apply to other kinds of
66
+works, such as semiconductor masks.
67
+
68
+  "The Program" refers to any copyrightable work licensed under this
69
+License.  Each licensee is addressed as "you".  "Licensees" and
70
+"recipients" may be individuals or organizations.
71
+
72
+  To "modify" a work means to copy from or adapt all or part of the work
73
+in a fashion requiring copyright permission, other than the making of an
74
+exact copy.  The resulting work is called a "modified version" of the
75
+earlier work or a work "based on" the earlier work.
76
+
77
+  A "covered work" means either the unmodified Program or a work based
78
+on the Program.
79
+
80
+  To "propagate" a work means to do anything with it that, without
81
+permission, would make you directly or secondarily liable for
82
+infringement under applicable copyright law, except executing it on a
83
+computer or modifying a private copy.  Propagation includes copying,
84
+distribution (with or without modification), making available to the
85
+public, and in some countries other activities as well.
86
+
87
+  To "convey" a work means any kind of propagation that enables other
88
+parties to make or receive copies.  Mere interaction with a user through
89
+a computer network, with no transfer of a copy, is not conveying.
90
+
91
+  An interactive user interface displays "Appropriate Legal Notices"
92
+to the extent that it includes a convenient and prominently visible
93
+feature that (1) displays an appropriate copyright notice, and (2)
94
+tells the user that there is no warranty for the work (except to the
95
+extent that warranties are provided), that licensees may convey the
96
+work under this License, and how to view a copy of this License.  If
97
+the interface presents a list of user commands or options, such as a
98
+menu, a prominent item in the list meets this criterion.
99
+
100
+  1. Source Code.
101
+
102
+  The "source code" for a work means the preferred form of the work
103
+for making modifications to it.  "Object code" means any non-source
104
+form of a work.
105
+
106
+  A "Standard Interface" means an interface that either is an official
107
+standard defined by a recognized standards body, or, in the case of
108
+interfaces specified for a particular programming language, one that
109
+is widely used among developers working in that language.
110
+
111
+  The "System Libraries" of an executable work include anything, other
112
+than the work as a whole, that (a) is included in the normal form of
113
+packaging a Major Component, but which is not part of that Major
114
+Component, and (b) serves only to enable use of the work with that
115
+Major Component, or to implement a Standard Interface for which an
116
+implementation is available to the public in source code form.  A
117
+"Major Component", in this context, means a major essential component
118
+(kernel, window system, and so on) of the specific operating system
119
+(if any) on which the executable work runs, or a compiler used to
120
+produce the work, or an object code interpreter used to run it.
121
+
122
+  The "Corresponding Source" for a work in object code form means all
123
+the source code needed to generate, install, and (for an executable
124
+work) run the object code and to modify the work, including scripts to
125
+control those activities.  However, it does not include the work's
126
+System Libraries, or general-purpose tools or generally available free
127
+programs which are used unmodified in performing those activities but
128
+which are not part of the work.  For example, Corresponding Source
129
+includes interface definition files associated with source files for
130
+the work, and the source code for shared libraries and dynamically
131
+linked subprograms that the work is specifically designed to require,
132
+such as by intimate data communication or control flow between those
133
+subprograms and other parts of the work.
134
+
135
+  The Corresponding Source need not include anything that users
136
+can regenerate automatically from other parts of the Corresponding
137
+Source.
138
+
139
+  The Corresponding Source for a work in source code form is that
140
+same work.
141
+
142
+  2. Basic Permissions.
143
+
144
+  All rights granted under this License are granted for the term of
145
+copyright on the Program, and are irrevocable provided the stated
146
+conditions are met.  This License explicitly affirms your unlimited
147
+permission to run the unmodified Program.  The output from running a
148
+covered work is covered by this License only if the output, given its
149
+content, constitutes a covered work.  This License acknowledges your
150
+rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+  You may make, run and propagate covered works that you do not
153
+convey, without conditions so long as your license otherwise remains
154
+in force.  You may convey covered works to others for the sole purpose
155
+of having them make modifications exclusively for you, or provide you
156
+with facilities for running those works, provided that you comply with
157
+the terms of this License in conveying all material for which you do
158
+not control copyright.  Those thus making or running the covered works
159
+for you must do so exclusively on your behalf, under your direction
160
+and control, on terms that prohibit them from making any copies of
161
+your copyrighted material outside their relationship with you.
162
+
163
+  Conveying under any other circumstances is permitted solely under
164
+the conditions stated below.  Sublicensing is not allowed; section 10
165
+makes it unnecessary.
166
+
167
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+  No covered work shall be deemed part of an effective technological
170
+measure under any applicable law fulfilling obligations under article
171
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+similar laws prohibiting or restricting circumvention of such
173
+measures.
174
+
175
+  When you convey a covered work, you waive any legal power to forbid
176
+circumvention of technological measures to the extent such circumvention
177
+is effected by exercising rights under this License with respect to
178
+the covered work, and you disclaim any intention to limit operation or
179
+modification of the work as a means of enforcing, against the work's
180
+users, your or third parties' legal rights to forbid circumvention of
181
+technological measures.
182
+
183
+  4. Conveying Verbatim Copies.
184
+
185
+  You may convey verbatim copies of the Program's source code as you
186
+receive it, in any medium, provided that you conspicuously and
187
+appropriately publish on each copy an appropriate copyright notice;
188
+keep intact all notices stating that this License and any
189
+non-permissive terms added in accord with section 7 apply to the code;
190
+keep intact all notices of the absence of any warranty; and give all
191
+recipients a copy of this License along with the Program.
192
+
193
+  You may charge any price or no price for each copy that you convey,
194
+and you may offer support or warranty protection for a fee.
195
+
196
+  5. Conveying Modified Source Versions.
197
+
198
+  You may convey a work based on the Program, or the modifications to
199
+produce it from the Program, in the form of source code under the
200
+terms of section 4, provided that you also meet all of these conditions:
201
+
202
+    a) The work must carry prominent notices stating that you modified
203
+    it, and giving a relevant date.
204
+
205
+    b) The work must carry prominent notices stating that it is
206
+    released under this License and any conditions added under section
207
+    7.  This requirement modifies the requirement in section 4 to
208
+    "keep intact all notices".
209
+
210
+    c) You must license the entire work, as a whole, under this
211
+    License to anyone who comes into possession of a copy.  This
212
+    License will therefore apply, along with any applicable section 7
213
+    additional terms, to the whole of the work, and all its parts,
214
+    regardless of how they are packaged.  This License gives no
215
+    permission to license the work in any other way, but it does not
216
+    invalidate such permission if you have separately received it.
217
+
218
+    d) If the work has interactive user interfaces, each must display
219
+    Appropriate Legal Notices; however, if the Program has interactive
220
+    interfaces that do not display Appropriate Legal Notices, your
221
+    work need not make them do so.
222
+
223
+  A compilation of a covered work with other separate and independent
224
+works, which are not by their nature extensions of the covered work,
225
+and which are not combined with it such as to form a larger program,
226
+in or on a volume of a storage or distribution medium, is called an
227
+"aggregate" if the compilation and its resulting copyright are not
228
+used to limit the access or legal rights of the compilation's users
229
+beyond what the individual works permit.  Inclusion of a covered work
230
+in an aggregate does not cause this License to apply to the other
231
+parts of the aggregate.
232
+
233
+  6. Conveying Non-Source Forms.
234
+
235
+  You may convey a covered work in object code form under the terms
236
+of sections 4 and 5, provided that you also convey the
237
+machine-readable Corresponding Source under the terms of this License,
238
+in one of these ways:
239
+
240
+    a) Convey the object code in, or embodied in, a physical product
241
+    (including a physical distribution medium), accompanied by the
242
+    Corresponding Source fixed on a durable physical medium
243
+    customarily used for software interchange.
244
+
245
+    b) Convey the object code in, or embodied in, a physical product
246
+    (including a physical distribution medium), accompanied by a
247
+    written offer, valid for at least three years and valid for as
248
+    long as you offer spare parts or customer support for that product
249
+    model, to give anyone who possesses the object code either (1) a
250
+    copy of the Corresponding Source for all the software in the
251
+    product that is covered by this License, on a durable physical
252
+    medium customarily used for software interchange, for a price no
253
+    more than your reasonable cost of physically performing this
254
+    conveying of source, or (2) access to copy the
255
+    Corresponding Source from a network server at no charge.
256
+
257
+    c) Convey individual copies of the object code with a copy of the
258
+    written offer to provide the Corresponding Source.  This
259
+    alternative is allowed only occasionally and noncommercially, and
260
+    only if you received the object code with such an offer, in accord
261
+    with subsection 6b.
262
+
263
+    d) Convey the object code by offering access from a designated
264
+    place (gratis or for a charge), and offer equivalent access to the
265
+    Corresponding Source in the same way through the same place at no
266
+    further charge.  You need not require recipients to copy the
267
+    Corresponding Source along with the object code.  If the place to
268
+    copy the object code is a network server, the Corresponding Source
269
+    may be on a different server (operated by you or a third party)
270
+    that supports equivalent copying facilities, provided you maintain
271
+    clear directions next to the object code saying where to find the
272
+    Corresponding Source.  Regardless of what server hosts the
273
+    Corresponding Source, you remain obligated to ensure that it is
274
+    available for as long as needed to satisfy these requirements.
275
+
276
+    e) Convey the object code using peer-to-peer transmission, provided
277
+    you inform other peers where the object code and Corresponding
278
+    Source of the work are being offered to the general public at no
279
+    charge under subsection 6d.
280
+
281
+  A separable portion of the object code, whose source code is excluded
282
+from the Corresponding Source as a System Library, need not be
283
+included in conveying the object code work.
284
+
285
+  A "User Product" is either (1) a "consumer product", which means any
286
+tangible personal property which is normally used for personal, family,
287
+or household purposes, or (2) anything designed or sold for incorporation
288
+into a dwelling.  In determining whether a product is a consumer product,
289
+doubtful cases shall be resolved in favor of coverage.  For a particular
290
+product received by a particular user, "normally used" refers to a
291
+typical or common use of that class of product, regardless of the status
292
+of the particular user or of the way in which the particular user
293
+actually uses, or expects or is expected to use, the product.  A product
294
+is a consumer product regardless of whether the product has substantial
295
+commercial, industrial or non-consumer uses, unless such uses represent
296
+the only significant mode of use of the product.
297
+
298
+  "Installation Information" for a User Product means any methods,
299
+procedures, authorization keys, or other information required to install
300
+and execute modified versions of a covered work in that User Product from
301
+a modified version of its Corresponding Source.  The information must
302
+suffice to ensure that the continued functioning of the modified object
303
+code is in no case prevented or interfered with solely because
304
+modification has been made.
305
+
306
+  If you convey an object code work under this section in, or with, or
307
+specifically for use in, a User Product, and the conveying occurs as
308
+part of a transaction in which the right of possession and use of the
309
+User Product is transferred to the recipient in perpetuity or for a
310
+fixed term (regardless of how the transaction is characterized), the
311
+Corresponding Source conveyed under this section must be accompanied
312
+by the Installation Information.  But this requirement does not apply
313
+if neither you nor any third party retains the ability to install
314
+modified object code on the User Product (for example, the work has
315
+been installed in ROM).
316
+
317
+  The requirement to provide Installation Information does not include a
318
+requirement to continue to provide support service, warranty, or updates
319
+for a work that has been modified or installed by the recipient, or for
320
+the User Product in which it has been modified or installed.  Access to a
321
+network may be denied when the modification itself materially and
322
+adversely affects the operation of the network or violates the rules and
323
+protocols for communication across the network.
324
+
325
+  Corresponding Source conveyed, and Installation Information provided,
326
+in accord with this section must be in a format that is publicly
327
+documented (and with an implementation available to the public in
328
+source code form), and must require no special password or key for
329
+unpacking, reading or copying.
330
+
331
+  7. Additional Terms.
332
+
333
+  "Additional permissions" are terms that supplement the terms of this
334
+License by making exceptions from one or more of its conditions.
335
+Additional permissions that are applicable to the entire Program shall
336
+be treated as though they were included in this License, to the extent
337
+that they are valid under applicable law.  If additional permissions
338
+apply only to part of the Program, that part may be used separately
339
+under those permissions, but the entire Program remains governed by
340
+this License without regard to the additional permissions.
341
+
342
+  When you convey a copy of a covered work, you may at your option
343
+remove any additional permissions from that copy, or from any part of
344
+it.  (Additional permissions may be written to require their own
345
+removal in certain cases when you modify the work.)  You may place
346
+additional permissions on material, added by you to a covered work,
347
+for which you have or can give appropriate copyright permission.
348
+
349
+  Notwithstanding any other provision of this License, for material you
350
+add to a covered work, you may (if authorized by the copyright holders of
351
+that material) supplement the terms of this License with terms:
352
+
353
+    a) Disclaiming warranty or limiting liability differently from the
354
+    terms of sections 15 and 16 of this License; or
355
+
356
+    b) Requiring preservation of specified reasonable legal notices or
357
+    author attributions in that material or in the Appropriate Legal
358
+    Notices displayed by works containing it; or
359
+
360
+    c) Prohibiting misrepresentation of the origin of that material, or
361
+    requiring that modified versions of such material be marked in
362
+    reasonable ways as different from the original version; or
363
+
364
+    d) Limiting the use for publicity purposes of names of licensors or
365
+    authors of the material; or
366
+
367
+    e) Declining to grant rights under trademark law for use of some
368
+    trade names, trademarks, or service marks; or
369
+
370
+    f) Requiring indemnification of licensors and authors of that
371
+    material by anyone who conveys the material (or modified versions of
372
+    it) with contractual assumptions of liability to the recipient, for
373
+    any liability that these contractual assumptions directly impose on
374
+    those licensors and authors.
375
+
376
+  All other non-permissive additional terms are considered "further
377
+restrictions" within the meaning of section 10.  If the Program as you
378
+received it, or any part of it, contains a notice stating that it is
379
+governed by this License along with a term that is a further
380
+restriction, you may remove that term.  If a license document contains
381
+a further restriction but permits relicensing or conveying under this
382
+License, you may add to a covered work material governed by the terms
383
+of that license document, provided that the further restriction does
384
+not survive such relicensing or conveying.
385
+
386
+  If you add terms to a covered work in accord with this section, you
387
+must place, in the relevant source files, a statement of the
388
+additional terms that apply to those files, or a notice indicating
389
+where to find the applicable terms.
390
+
391
+  Additional terms, permissive or non-permissive, may be stated in the
392
+form of a separately written license, or stated as exceptions;
393
+the above requirements apply either way.
394
+
395
+  8. Termination.
396
+
397
+  You may not propagate or modify a covered work except as expressly
398
+provided under this License.  Any attempt otherwise to propagate or
399
+modify it is void, and will automatically terminate your rights under
400
+this License (including any patent licenses granted under the third
401
+paragraph of section 11).
402
+
403
+  However, if you cease all violation of this License, then your
404
+license from a particular copyright holder is reinstated (a)
405
+provisionally, unless and until the copyright holder explicitly and
406
+finally terminates your license, and (b) permanently, if the copyright
407
+holder fails to notify you of the violation by some reasonable means
408
+prior to 60 days after the cessation.
409
+
410
+  Moreover, your license from a particular copyright holder is
411
+reinstated permanently if the copyright holder notifies you of the
412
+violation by some reasonable means, this is the first time you have
413
+received notice of violation of this License (for any work) from that
414
+copyright holder, and you cure the violation prior to 30 days after
415
+your receipt of the notice.
416
+
417
+  Termination of your rights under this section does not terminate the
418
+licenses of parties who have received copies or rights from you under
419
+this License.  If your rights have been terminated and not permanently
420
+reinstated, you do not qualify to receive new licenses for the same
421
+material under section 10.
422
+
423
+  9. Acceptance Not Required for Having Copies.
424
+
425
+  You are not required to accept this License in order to receive or
426
+run a copy of the Program.  Ancillary propagation of a covered work
427
+occurring solely as a consequence of using peer-to-peer transmission
428
+to receive a copy likewise does not require acceptance.  However,
429
+nothing other than this License grants you permission to propagate or
430
+modify any covered work.  These actions infringe copyright if you do
431
+not accept this License.  Therefore, by modifying or propagating a
432
+covered work, you indicate your acceptance of this License to do so.
433
+
434
+  10. Automatic Licensing of Downstream Recipients.
435
+
436
+  Each time you convey a covered work, the recipient automatically
437
+receives a license from the original licensors, to run, modify and
438
+propagate that work, subject to this License.  You are not responsible
439
+for enforcing compliance by third parties with this License.
440
+
441
+  An "entity transaction" is a transaction transferring control of an
442
+organization, or substantially all assets of one, or subdividing an
443
+organization, or merging organizations.  If propagation of a covered
444
+work results from an entity transaction, each party to that
445
+transaction who receives a copy of the work also receives whatever
446
+licenses to the work the party's predecessor in interest had or could
447
+give under the previous paragraph, plus a right to possession of the
448
+Corresponding Source of the work from the predecessor in interest, if
449
+the predecessor has it or can get it with reasonable efforts.
450
+
451
+  You may not impose any further restrictions on the exercise of the
452
+rights granted or affirmed under this License.  For example, you may
453
+not impose a license fee, royalty, or other charge for exercise of
454
+rights granted under this License, and you may not initiate litigation
455
+(including a cross-claim or counterclaim in a lawsuit) alleging that
456
+any patent claim is infringed by making, using, selling, offering for
457
+sale, or importing the Program or any portion of it.
458
+
459
+  11. Patents.
460
+
461
+  A "contributor" is a copyright holder who authorizes use under this
462
+License of the Program or a work on which the Program is based.  The
463
+work thus licensed is called the contributor's "contributor version".
464
+
465
+  A contributor's "essential patent claims" are all patent claims
466
+owned or controlled by the contributor, whether already acquired or
467
+hereafter acquired, that would be infringed by some manner, permitted
468
+by this License, of making, using, or selling its contributor version,
469
+but do not include claims that would be infringed only as a
470
+consequence of further modification of the contributor version.  For
471
+purposes of this definition, "control" includes the right to grant
472
+patent sublicenses in a manner consistent with the requirements of
473
+this License.
474
+
475
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+patent license under the contributor's essential patent claims, to
477
+make, use, sell, offer for sale, import and otherwise run, modify and
478
+propagate the contents of its contributor version.
479
+
480
+  In the following three paragraphs, a "patent license" is any express
481
+agreement or commitment, however denominated, not to enforce a patent
482
+(such as an express permission to practice a patent or covenant not to
483
+sue for patent infringement).  To "grant" such a patent license to a
484
+party means to make such an agreement or commitment not to enforce a
485
+patent against the party.
486
+
487
+  If you convey a covered work, knowingly relying on a patent license,
488
+and the Corresponding Source of the work is not available for anyone
489
+to copy, free of charge and under the terms of this License, through a
490
+publicly available network server or other readily accessible means,
491
+then you must either (1) cause the Corresponding Source to be so
492
+available, or (2) arrange to deprive yourself of the benefit of the
493
+patent license for this particular work, or (3) arrange, in a manner
494
+consistent with the requirements of this License, to extend the patent
495
+license to downstream recipients.  "Knowingly relying" means you have
496
+actual knowledge that, but for the patent license, your conveying the
497
+covered work in a country, or your recipient's use of the covered work
498
+in a country, would infringe one or more identifiable patents in that
499
+country that you have reason to believe are valid.
500
+
501
+  If, pursuant to or in connection with a single transaction or
502
+arrangement, you convey, or propagate by procuring conveyance of, a
503
+covered work, and grant a patent license to some of the parties
504
+receiving the covered work authorizing them to use, propagate, modify
505
+or convey a specific copy of the covered work, then the patent license
506
+you grant is automatically extended to all recipients of the covered
507
+work and works based on it.
508
+
509
+  A patent license is "discriminatory" if it does not include within
510
+the scope of its coverage, prohibits the exercise of, or is
511
+conditioned on the non-exercise of one or more of the rights that are
512
+specifically granted under this License.  You may not convey a covered
513
+work if you are a party to an arrangement with a third party that is
514
+in the business of distributing software, under which you make payment
515
+to the third party based on the extent of your activity of conveying
516
+the work, and under which the third party grants, to any of the
517
+parties who would receive the covered work from you, a discriminatory
518
+patent license (a) in connection with copies of the covered work
519
+conveyed by you (or copies made from those copies), or (b) primarily
520
+for and in connection with specific products or compilations that
521
+contain the covered work, unless you entered into that arrangement,
522
+or that patent license was granted, prior to 28 March 2007.
523
+
524
+  Nothing in this License shall be construed as excluding or limiting
525
+any implied license or other defenses to infringement that may
526
+otherwise be available to you under applicable patent law.
527
+
528
+  12. No Surrender of Others' Freedom.
529
+
530
+  If conditions are imposed on you (whether by court order, agreement or
531
+otherwise) that contradict the conditions of this License, they do not
532
+excuse you from the conditions of this License.  If you cannot convey a
533
+covered work so as to satisfy simultaneously your obligations under this
534
+License and any other pertinent obligations, then as a consequence you may
535
+not convey it at all.  For example, if you agree to terms that obligate you
536
+to collect a royalty for further conveying from those to whom you convey
537
+the Program, the only way you could satisfy both those terms and this
538
+License would be to refrain entirely from conveying the Program.
539
+
540
+  13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+  Notwithstanding any other provision of this License, if you modify the
543
+Program, your modified version must prominently offer all users
544
+interacting with it remotely through a computer network (if your version
545
+supports such interaction) an opportunity to receive the Corresponding
546
+Source of your version by providing access to the Corresponding Source
547
+from a network server at no charge, through some standard or customary
548
+means of facilitating copying of software.  This Corresponding Source
549
+shall include the Corresponding Source for any work covered by version 3
550
+of the GNU General Public License that is incorporated pursuant to the
551
+following paragraph.
552
+
553
+  Notwithstanding any other provision of this License, you have
554
+permission to link or combine any covered work with a work licensed
555
+under version 3 of the GNU General Public License into a single
556
+combined work, and to convey the resulting work.  The terms of this
557
+License will continue to apply to the part which is the covered work,
558
+but the work with which it is combined will remain governed by version
559
+3 of the GNU General Public License.
560
+
561
+  14. Revised Versions of this License.
562
+
563
+  The Free Software Foundation may publish revised and/or new versions of
564
+the GNU Affero General Public License from time to time.  Such new versions
565
+will be similar in spirit to the present version, but may differ in detail to
566
+address new problems or concerns.
567
+
568
+  Each version is given a distinguishing version number.  If the
569
+Program specifies that a certain numbered version of the GNU Affero General
570
+Public License "or any later version" applies to it, you have the
571
+option of following the terms and conditions either of that numbered
572
+version or of any later version published by the Free Software
573
+Foundation.  If the Program does not specify a version number of the
574
+GNU Affero General Public License, you may choose any version ever published
575
+by the Free Software Foundation.
576
+
577
+  If the Program specifies that a proxy can decide which future
578
+versions of the GNU Affero General Public License can be used, that proxy's
579
+public statement of acceptance of a version permanently authorizes you
580
+to choose that version for the Program.
581
+
582
+  Later license versions may give you additional or different
583
+permissions.  However, no additional obligations are imposed on any
584
+author or copyright holder as a result of your choosing to follow a
585
+later version.
586
+
587
+  15. Disclaimer of Warranty.
588
+
589
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+  16. Limitation of Liability.
599
+
600
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+SUCH DAMAGES.
609
+
610
+  17. Interpretation of Sections 15 and 16.
611
+
612
+  If the disclaimer of warranty and limitation of liability provided
613
+above cannot be given local legal effect according to their terms,
614
+reviewing courts shall apply local law that most closely approximates
615
+an absolute waiver of all civil liability in connection with the
616
+Program, unless a warranty or assumption of liability accompanies a
617
+copy of the Program in return for a fee.
618
+
619
+                     END OF TERMS AND CONDITIONS
620
+
621
+            How to Apply These Terms to Your New Programs
622
+
623
+  If you develop a new program, and you want it to be of the greatest
624
+possible use to the public, the best way to achieve this is to make it
625
+free software which everyone can redistribute and change under these terms.
626
+
627
+  To do so, attach the following notices to the program.  It is safest
628
+to attach them to the start of each source file to most effectively
629
+state the exclusion of warranty; and each file should have at least
630
+the "copyright" line and a pointer to where the full notice is found.
631
+
632
+    <one line to give the program's name and a brief idea of what it does.>
633
+    Copyright (C) <year>  <name of author>
634
+
635
+    This program is free software: you can redistribute it and/or modify
636
+    it under the terms of the GNU Affero General Public License as published by
637
+    the Free Software Foundation, either version 3 of the License, or
638
+    (at your option) any later version.
639
+
640
+    This program is distributed in the hope that it will be useful,
641
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
643
+    GNU Affero General Public License for more details.
644
+
645
+    You should have received a copy of the GNU Affero General Public License
646
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
647
+
648
+Also add information on how to contact you by electronic and paper mail.
649
+
650
+  If your software can interact with users remotely through a computer
651
+network, you should also make sure that it provides a way for users to
652
+get its source.  For example, if your program is a web application, its
653
+interface could display a "Source" link that leads users to an archive
654
+of the code.  There are many ways you could offer source, and different
655
+solutions will be better for different programs; see section 13 for the
656
+specific requirements.
657
+
658
+  You should also get your employer (if you work as a programmer) or school,
659
+if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+For more information on this, and how to apply and follow the GNU AGPL, see
661
+<http://www.gnu.org/licenses/>.

+ 98
- 0
README.md View File

@@ -0,0 +1,98 @@
1
+# freefrog
2
+
3
+Exquisite Organization -- For Free
4
+
5
+## Information
6
+
7
+This project is being integrated using
8
+[Travis-CI](https://travis-ci.org/).
9
+
10
+[![Build Status](https://travis-ci.org/couragelabs/freefrog.svg?branch=master)](https://travis-ci.org/couragelabs/freefrog)
11
+
12
+[![Dependencies Status](http://jarkeeper.com/couragelabs/freefrog/status.svg)](http://jarkeeper.com/couragelabs/freefrog)
13
+
14
+Artifacts generated:
15
+
16
+ * [API Documentation](http://s3.amazonaws.com/freefrog/docs/uberdoc.html)
17
+ * [Specs](http://s3.amazonaws.com/freefrog/docs/specs.txt)
18
+
19
+## Development
20
+
21
+### Getting Started
22
+
23
+Note: we all use Macs, so some commands in here (like "open") may not work
24
+on our linux machine unless you've aliased them. 
25
+
26
+Also, you'll need [Homebrew](http://brew.sh/) so you can:
27
+
28
+    brew install gnu-sed
29
+
30
+### Contributing
31
+
32
+The maintainers accept pull requests gratefully. You can submit whatever you 
33
+are inspired to submit and we promise to:
34
+
35
+ * Accept without changes, or
36
+ * Tell you what we would need in order to accept it.
37
+
38
+If you contribute enough we will probably invite you to become a committer.
39
+
40
+If you contribute even more we may invite you to become a partner in Courage Labs.
41
+
42
+If you'd like to see a list that the maintainers believe we should build next,
43
+you can visit [our Trello board](https://trello.com/b/NwocOwAv/freefrog). Don't
44
+feel limited by that list. We could be wrong!
45
+
46
+**Before submitting a pull request** run:
47
+
48
+    ./full-build
49
+
50
+This will run the same stuff our continuous integration server runs. This way, 
51
+you can know if you broke the build BEFORE your code makes it into master,
52
+keeping everything nice and clean.
53
+
54
+What to do if ancient.txt is not empty:
55
+
56
+    lein ancient upgrade :no-tests && git add project.clj && ./full-build
57
+
58
+### Various commands
59
+
60
+Running the specs once (SLOW):
61
+
62
+    lein spec
63
+
64
+Or autotest (SLOW to start, then FAST to develop):
65
+
66
+    lein autotest
67
+
68
+To see what the documentation looks like:
69
+
70
+    lein docs && open docs/uberdoc.html
71
+
72
+## Running it locally (COMING SOON -- once we make this a real app again)
73
+
74
+    lein freefrog
75
+
76
+## Operating using Docker (COMING SOON)
77
+
78
+Docker is our preferred approach for operating Freefrog. An example file
79
+can be found in the root:
80
+
81
+    ./run-with-docker
82
+
83
+## License
84
+
85
+Copyright © 2015 Courage Labs
86
+
87
+This program is free software: you can redistribute it and/or modify
88
+it under the terms of the GNU Affero General Public License as published by
89
+the Free Software Foundation, either version 3 of the License, or
90
+(at your option) any later version.
91
+
92
+This program is distributed in the hope that it will be useful,
93
+but WITHOUT ANY WARRANTY; without even the implied warranty of
94
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
95
+GNU Affero General Public License for more details.
96
+
97
+You should have received a copy of the GNU Affero General Public License
98
+along with this program.  If not, see <http://www.gnu.org/licenses/>.

+ 8
- 0
fail-if-nonempty View File

@@ -0,0 +1,8 @@
1
+#!/bin/bash
2
+export COUNT=`wc -w $1 | awk '{print $1}'`
3
+if [ "$COUNT" -ne "0" ]
4
+  then
5
+  echo "** BUILD FAILED: " $1 is NOT EMPTY "**"
6
+  cat $1
7
+  exit 1
8
+fi

+ 16
- 0
full-build View File

@@ -0,0 +1,16 @@
1
+#!/bin/bash
2
+mkdir -p docs
3
+lein ancient > docs/ancient.txt
4
+
5
+if [ "$(uname)" == "Darwin" ]; then
6
+  sed -i '' '/up-to-date/d' docs/ancient.txt
7
+elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
8
+  sed -i '/up-to-date/d' docs/ancient.txt
9
+fi
10
+
11
+./fail-if-nonempty docs/ancient.txt &&
12
+lein kibit > docs/kibit.txt &&
13
+./fail-if-nonempty docs/kibit.txt &&
14
+lein bikeshed &&
15
+lein spec -f d -C > docs/specs.txt &&
16
+lein docs

+ 61
- 0
project.clj View File

@@ -0,0 +1,61 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+(defproject freefrog "0.0.1-SNAPSHOT"
21
+  :description "freefrog"
22
+  :url "http://www.couragelabs.com"
23
+  :license {:name "GNU Affero General Public License"
24
+            :url  "http://www.gnu.org/licenses/agpl-3.0.html"}
25
+
26
+  :min-lein-version "2.3.4"
27
+
28
+  :source-paths ["src/clj" "src/java"]
29
+
30
+  :java-source-paths ["src/java"]
31
+
32
+  :dependencies [[clj-http "2.1.0"]
33
+                 [clj-json "0.5.3"]
34
+                 [clj-time "0.11.0"]
35
+                 [selmer "1.0.2"]
36
+                 [instaparse "1.4.1"]
37
+                 [org.clojure/clojure "1.7.0"]
38
+                 [org.clojure/tools.cli "0.3.3"]
39
+                 [org.clojure/tools.logging "0.3.1"]
40
+                 [speclj "3.3.1"]]
41
+
42
+  :profiles {:uberjar {:aot :all}
43
+             :dev {
44
+                   :plugins [[lein-clojars "0.9.1"]]
45
+                   :dependencies [[clj-yaml "0.4.0"]]}
46
+             :1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
47
+             :cli {:main freefrog.cli}}
48
+
49
+  :plugins [[lein-ancient "0.6.7"]
50
+            [lein-bikeshed "0.2.0"]
51
+            [lein-kibit "0.1.2"]
52
+            [lein-marginalia "0.8.0"]
53
+            [speclj "3.2.0"]]
54
+
55
+  :test-paths ["spec"]
56
+
57
+  :aliases {"autotest" ["spec" "-a"]
58
+            "docs" ["with-profile" "1.6" "marg" "src" "spec"]
59
+            "cli" ["with-profile" "cli" "run"]}
60
+
61
+  :main freefrog.cli)

+ 43
- 0
resources/governance.ebnf View File

@@ -0,0 +1,43 @@
1
+<document> = [govern], { block }
2
+govern = <"govern">, ws, ( circle | role ), ws, name, <".">, cr, { cr }
3
+<block> = resolution | <comment>
4
+<resolution> = ( create | update | delete | convert | define | strike | elect |
5
+                 appoint | unappoint),
6
+               <".">, { ws }
7
+create = <"create">, ws, entity, ws, name, [ws, <"with">, ws, create-components]
8
+update = <"update">, ws, entity, ws, name, ws, update-action-list
9
+delete = <"delete">, ws, entity, ws, name
10
+define = <"define policy">, ws, name, ws, <"as">, ws, name
11
+strike = <"strike policy">, ws, name
12
+elect = <"elect">, ws, name, ws, <"as">, ws,
13
+        [ "facilitator" | "secretary" | "rep link" ], ws, <"expiring">, ws,
14
+        #"\d{4}-\d{2}-\d{2}"
15
+appoint = <"appoint">, ws, name, ws, <"to">, ws, name, { ws, <"with focus">,
16
+          ws, name }
17
+unappoint = <"unappoint">, ws, name, ws, <"from">, ws, name
18
+convert = <"convert">, ws, entity, ws, name, ws, <"into a">, ws, entity
19
+comment = <"--">, comment-text, cr, { cr }
20
+comment-text = #'[^\n]*'
21
+<cr> = <"\n">
22
+<text> = #"[^\"]*"
23
+<update-action-list> = update-action, { ws <"and"> ws update-action }
24
+<update-action> = add | remove | change-purpose | rename
25
+add = <"add">, ws, component
26
+remove = <"remove">, ws, component
27
+change-purpose = <"change purpose to">, ws, name
28
+rename = <"rename to">, ws, name
29
+<ws> = <#'\s+'>
30
+<entity> = anchor-circle | circle | role
31
+anchor-circle = <"anchor circle">
32
+circle = <"circle">
33
+role = <"role">
34
+<name> = <'"'>, text, <'"'>
35
+
36
+<create-components> = component, { ws <"and"> ws component }
37
+<component> = purpose | accountabilities | domains | cross-links
38
+purpose = <"purpose">, ws, name
39
+accountabilities = <"accountability">, ws, name | <"accountabilities">, ws,
40
+                   name-list
41
+domains = <"domain">, ws, name | <"domains">, ws, name-list
42
+cross-links = <"cross-link">, ws, name | <"cross-links">, ws, name-list
43
+<name-list> = name, { <",">, ws, name }

+ 5
- 0
run-with-docker View File

@@ -0,0 +1,5 @@
1
+#!/bin/bash
2
+`boot2docker shellinit`
3
+lein uberjar &&
4
+  docker build -t freefrog . &&
5
+  docker run -e AUTH_AUDIENCE_URL="http://$(boot2docker ip):3000" -p 3000:3000 freefrog

+ 470
- 0
spec/freefrog/governance_circles_spec.clj View File

@@ -0,0 +1,470 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+;;; # Circle Manipulation Spec #
21
+;;; Defines how circles may be updated.
22
+(ns freefrog.governance-circles-spec
23
+  (:require [freefrog.governance :as g]
24
+            [freefrog.governance-spec-helpers :refer :all]
25
+            [speclj.core :refer :all]
26
+            [clj-time.core :as t])
27
+  (:import (java.lang IllegalArgumentException)))
28
+
29
+(def sample-anchor-with-sample-policy
30
+  (my-add-policy sample-anchor-with-role "test" "stuff"))
31
+
32
+;; Section 2.1
33
+(describe "Circles"
34
+  (it "can create a circle"
35
+    (should= (g/map->Circle {:rname "Courage Labs"})
36
+      (g/create-circle "Courage Labs")))
37
+
38
+  (it "doesn't work with an empty name"
39
+    (should-throw IllegalArgumentException "Circle name may not be empty"
40
+      (g/create-circle nil))
41
+    (should-throw IllegalArgumentException "Circle name may not be empty"
42
+      (g/create-circle "")))
43
+
44
+  (it "can tell you if a role is authorized to act as a circle"
45
+    (should (g/is-circle? sample-anchor-with-role))
46
+    (should-not (g/is-subrole-circle? sample-anchor-with-role role-name)))
47
+
48
+  (it "can convert a role into a circle"
49
+    (should (g/is-subrole-circle?
50
+              (g/convert-to-circle sample-anchor-with-role role-name)
51
+              role-name)))
52
+
53
+  (it "refuses to convert a role that is already a circle into a circle"
54
+    (should-throw IllegalArgumentException
55
+      (format "Role '%s' is already a circle" role-name)
56
+      (-> sample-anchor-with-role
57
+          (g/convert-to-circle role-name)
58
+          (g/convert-to-circle role-name))))
59
+
60
+  (it "can convert an empty circle back into a role"
61
+    (should (.equals sample-anchor-with-role
62
+                     (-> sample-anchor-with-role
63
+                         (g/convert-to-circle role-name)
64
+                         (g/convert-to-role role-name)))))
65
+
66
+  (it "refuses to convert a non-empty circle into a role"
67
+    (should-throw IllegalArgumentException
68
+      (format "Circle %s still contains roles" role-name)
69
+      (let [circle-with-full-subcircle
70
+            (-> sample-anchor-with-role
71
+                (g/convert-to-circle role-name)
72
+                (g/update-subcircle [role-name] g/add-role-to-circle
73
+                                    "Fun"))]
74
+        (g/convert-to-role circle-with-full-subcircle role-name))))
75
+
76
+  (it "refuses to convert a role that isn't a circle into a role"
77
+    (should-throw IllegalArgumentException
78
+      (format "Role '%s' is not a circle" role-name)
79
+      (g/convert-to-role sample-anchor-with-role role-name)))
80
+
81
+  (should-not-update-missing-or-empty-roles g/convert-to-circle
82
+    "convert to circle")
83
+  (should-not-update-missing-or-empty-roles g/convert-to-role
84
+    "convert to role")
85
+
86
+  ;; TODO unify this with the role-specific code because there is a TON
87
+  ;; of validation and behavior in there
88
+  (describe "policies"
89
+    (describe "adding"
90
+      (it "can add to a circle with no policies"
91
+        (should= sample-anchor-with-sample-policy
92
+          (g/add-policy sample-anchor-with-role "test" "stuff"))))
93
+
94
+    (describe "removing"
95
+      (it "can remove a policy from a circle"
96
+        (should= sample-anchor-with-role
97
+          (g/remove-policy sample-anchor-with-sample-policy "test"))))))
98
+
99
+
100
+(def sample-policy-name "Do whatever")
101
+(def sample-policy-text "Anybody can do anything whenever")
102
+
103
+(def sample-policies-lead-link {sample-policy-name
104
+                                {:domain g/role-assignments-domain
105
+                                 :text   sample-policy-text}})
106
+
107
+(def sample-policies-secretary {sample-policy-name
108
+                                {:domain g/governance-records-domain
109
+                                 :text   sample-policy-text}})
110
+(def sample-policy-name2 "Do things to other people")
111
+(def sample-policy-text2 "Anybody do things to anyone else")
112
+
113
+(def sample-anchor-with-lead-link-policy
114
+  (g/add-role-policy sample-anchor g/lead-link-name sample-policy-name
115
+                     sample-policy-text g/role-assignments-domain))
116
+
117
+(def sample-anchor-with-lead-link-policies
118
+  (g/add-role-policy sample-anchor-with-lead-link-policy g/lead-link-name
119
+                     sample-policy-name2 sample-policy-text2))
120
+
121
+(def sample-anchor-with-secretary-policy
122
+  (g/add-role-policy sample-anchor g/secretary-name sample-policy-name
123
+                     sample-policy-text g/governance-records-domain))
124
+
125
+(def sample-anchor-with-secretary-policies
126
+  (g/add-role-policy sample-anchor-with-secretary-policy g/secretary-name
127
+                     sample-policy-name2 sample-policy-text2))
128
+
129
+;; Section 2.2.3
130
+(describe "Lead Link Role"
131
+  (it "won't add domains to the Lead Link"
132
+    (should-throw IllegalArgumentException
133
+      (format "May not add Domain to '%s'" g/lead-link-name)
134
+      (g/add-role-domain sample-anchor g/lead-link-name "test"))
135
+
136
+    (should-throw IllegalArgumentException
137
+      (format "May not add Domain to '%s'" g/lead-link-name)
138
+      (g/add-role-domain sample-anchor-with-lead-link-policy
139
+                         g/lead-link-name "test")))
140
+
141
+  (it "won't add accountabilities to the Lead Link"
142
+    (should-throw IllegalArgumentException
143
+      (format "May not add Accountability to '%s'" g/lead-link-name)
144
+      (g/add-role-accountability sample-anchor g/lead-link-name "test"))
145
+
146
+    (should-throw IllegalArgumentException
147
+      (format "May not add Accountability to '%s'" g/lead-link-name)
148
+      (g/add-role-accountability sample-anchor-with-lead-link-policy
149
+                                 g/lead-link-name "test")))
150
+
151
+  (describe "adding policies"
152
+    (it "can delegate a predefined domain from Lead Link"
153
+      (should=
154
+        (update-in sample-anchor [:roles] assoc g/lead-link-name
155
+                   (g/map->Role {:rname    g/lead-link-name
156
+                                 :policies sample-policies-lead-link}))
157
+        sample-anchor-with-lead-link-policy))
158
+
159
+    (it "won't create policies for domains Lead Link doesn't have"
160
+      (should-throw IllegalArgumentException
161
+        "Role 'Lead Link' doesn't control domain 'domain it doesn't have'"
162
+        (g/add-role-policy sample-anchor g/lead-link-name sample-policy-name
163
+                           sample-policy-text "domain it doesn't have")))
164
+
165
+    (it "can create multiple policies"
166
+      (should=
167
+        (update-in sample-anchor [:roles] assoc g/lead-link-name
168
+                   (g/map->Role {:rname g/lead-link-name
169
+                                 :policies
170
+                                        (assoc sample-policies-lead-link
171
+                                               sample-policy-name2
172
+                                               {:text sample-policy-text2})}))
173
+        sample-anchor-with-lead-link-policies)))
174
+
175
+  (describe "removing policies"
176
+    (it "removes Lead Link when it is empty"
177
+      (should= sample-anchor
178
+        (g/remove-role-policy sample-anchor-with-lead-link-policy
179
+                              g/lead-link-name sample-policy-name)))
180
+
181
+    (it "doesn't remove Lead Link when it isn't empty"
182
+      (should= sample-anchor-with-lead-link-policy
183
+        (g/remove-role-policy sample-anchor-with-lead-link-policies
184
+                              g/lead-link-name sample-policy-name2)))))
185
+
186
+(def sample-domain1 "stuff")
187
+(def sample-domain2 "bits")
188
+
189
+(def sample-anchor-with-secretary-with-domain
190
+  (g/add-role-domain sample-anchor g/secretary-name sample-domain1))
191
+
192
+(def sample-anchor-with-secretary-with-domains
193
+  (g/add-role-domain sample-anchor-with-secretary-with-domain
194
+                     g/secretary-name sample-domain2))
195
+
196
+(def sample-anchor-with-facilitator-with-domain
197
+  (g/add-role-domain sample-anchor g/facilitator-name sample-domain1))
198
+
199
+(def sample-anchor-with-facilitator-with-domains
200
+  (g/add-role-domain sample-anchor-with-facilitator-with-domain
201
+                     g/facilitator-name sample-domain2))
202
+
203
+(def sample-anchor-with-rep-link-with-domain
204
+  (g/add-role-domain sample-anchor g/rep-link-name sample-domain1))
205
+
206
+(def sample-anchor-with-rep-link-with-domains
207
+  (g/add-role-domain sample-anchor-with-rep-link-with-domain
208
+                     g/rep-link-name sample-domain2))
209
+
210
+(def sample-acc1 "doing stuff")
211
+(def sample-acc2 "doing bits")
212
+
213
+(def sample-anchor-with-secretary-with-acc
214
+  (g/add-role-accountability sample-anchor g/secretary-name sample-acc1))
215
+
216
+(def sample-anchor-with-secretary-with-accs
217
+  (g/add-role-accountability sample-anchor-with-secretary-with-acc
218
+                             g/secretary-name sample-acc2))
219
+
220
+(def sample-anchor-with-facilitator-with-acc
221
+  (g/add-role-accountability sample-anchor g/facilitator-name sample-acc1))
222
+
223
+(def sample-anchor-with-facilitator-with-accs
224
+  (g/add-role-accountability sample-anchor-with-facilitator-with-acc
225
+                             g/facilitator-name sample-acc2))
226
+
227
+(def sample-anchor-with-rep-link-with-acc
228
+  (g/add-role-accountability sample-anchor g/rep-link-name sample-acc1))
229
+
230
+(def sample-anchor-with-rep-link-with-accs
231
+  (g/add-role-accountability sample-anchor-with-rep-link-with-acc
232
+                             g/rep-link-name sample-acc2))
233
+
234
+(def sample-anchor-with-rep-link-with-acc-and-domain
235
+  (g/add-role-domain sample-anchor-with-rep-link-with-acc
236
+                     g/rep-link-name sample-domain1))
237
+
238
+(defn- should-manipulate-things-in-core-role
239
+  [role-name description which-things sample-with-one sample-with-two first
240
+   second removal-fn]
241
+  (describe (format "%s %s" role-name description)
242
+    (it "can add one"
243
+      (should= (update-in sample-anchor [:roles] assoc role-name
244
+                          (g/map->Role {:rname       role-name
245
+                                        which-things #{first}}))
246
+        sample-with-one))
247
+
248
+    (it "can add second one"
249
+      (should= (update-in sample-with-one
250
+                          [:roles role-name which-things] conj
251
+                          second)
252
+        sample-with-two))
253
+
254
+    (it "removes role when last one is removed"
255
+      (should= sample-anchor
256
+        (removal-fn sample-with-one role-name first)))
257
+
258
+    (it "doesn't remove role when second-to-last one is removed"
259
+      (should= sample-with-one
260
+        (removal-fn sample-with-two role-name second)))))
261
+
262
+;; Section 2.4
263
+(let [assignee-name "larry"
264
+      focus-assignee-name "george"
265
+      sample-anchor-with-assignee
266
+      (g/appoint-to-role sample-anchor-with-two-roles tester-role
267
+                         assignee-name)
268
+
269
+      sample-anchor-with-assignee-with-focus
270
+      (g/appoint-to-role sample-anchor-with-role role-name focus-assignee-name
271
+                         "cool stuff")]
272
+
273
+  (describe "Role Appointment"
274
+    (it "can appoint someone to a role"
275
+      (should= (update-in sample-anchor-with-role
276
+                          [:roles role-name] assoc :assignees
277
+                          {"susan" nil})
278
+        (g/appoint-to-role sample-anchor-with-role role-name "susan"))
279
+
280
+      (should= (update-in sample-anchor-with-two-roles
281
+                          [:roles tester-role] assoc :assignees
282
+                          {"larry" nil})
283
+        sample-anchor-with-assignee)
284
+
285
+      (should= (update-in sample-anchor-with-assignee
286
+                          [:roles tester-role :assignees] assoc
287
+                          "jane" nil)
288
+        (g/appoint-to-role sample-anchor-with-assignee tester-role "jane")))
289
+
290
+    (it "can appoint someone to a role with a focus"
291
+      (should= (update-in sample-anchor-with-role
292
+                          [:roles role-name] assoc :assignees
293
+                          {focus-assignee-name "cool stuff"})
294
+        sample-anchor-with-assignee-with-focus))
295
+
296
+    (it "can remove someone from a role"
297
+      (should= sample-anchor-with-two-roles
298
+        (g/unappoint-from-role sample-anchor-with-assignee tester-role
299
+                               assignee-name)))
300
+
301
+    (should-not-update-missing-or-empty-roles g/appoint-to-role
302
+      "role assignment" "june")
303
+
304
+    (should-not-update-missing-or-empty-roles g/appoint-to-role
305
+      "role assignment" "june" "some focus")
306
+
307
+    (should-not-update-missing-or-empty-roles g/unappoint-from-role
308
+      "role unassignment" "june")
309
+
310
+    (it "won't appoint nil to a role"
311
+      (should-throw IllegalArgumentException
312
+        "Person name may not be empty"
313
+        (g/appoint-to-role sample-anchor-with-role role-name nil)))
314
+
315
+    (it "won't unappoint someone who wasn't in the role"
316
+      (should-throw IllegalArgumentException
317
+        (format "Person 'june' is not in role '%s'" tester-role)
318
+        (g/unappoint-from-role sample-anchor-with-assignee tester-role
319
+                               "june")))))
320
+
321
+
322
+;; Section 2.5
323
+(describe "Elected Roles"
324
+  ;; Section 2.5.2
325
+
326
+  (let [expiration-date (t/date-time 2014 01 01)]
327
+    (describe "holding elections"
328
+      (it "can't elect someone to a non-core role"
329
+        (should-throw IllegalArgumentException
330
+          (format "'%s' is not an elected role." role-name)
331
+          (g/elect-to-role sample-anchor-with-role role-name "bill"
332
+                           expiration-date)))
333
+      (it "can specify that an elected role has had someone elected to it
334
+       and when their term expires"
335
+        (should= (assoc sample-anchor :facilitator
336
+                        {:rname           "bill"
337
+                         :expiration-date expiration-date})
338
+          (g/elect-to-role sample-anchor g/facilitator-name "bill"
339
+                           expiration-date))
340
+
341
+        (should= (assoc sample-anchor :secretary
342
+                        {:rname           "mary"
343
+                         :expiration-date expiration-date})
344
+          (g/elect-to-role sample-anchor g/secretary-name "mary"
345
+                           expiration-date))
346
+
347
+        (should= (assoc sample-anchor :rep-link
348
+                        {:rname           "mary"
349
+                         :expiration-date expiration-date})
350
+          (g/elect-to-role sample-anchor g/rep-link-name "mary"
351
+                           expiration-date)))))
352
+
353
+  ;; Section 2.5.3
354
+  (should-manipulate-things-in-core-role
355
+    g/secretary-name "domains"
356
+    :domains sample-anchor-with-secretary-with-domain
357
+    sample-anchor-with-secretary-with-domains
358
+    sample-domain1 sample-domain2 g/remove-role-domain)
359
+
360
+  (should-manipulate-things-in-core-role
361
+    g/secretary-name "accountabilities"
362
+    :accountabilities sample-anchor-with-secretary-with-acc
363
+    sample-anchor-with-secretary-with-accs
364
+    sample-acc1 sample-acc2 g/remove-role-accountability)
365
+
366
+  (should-manipulate-things-in-core-role
367
+    g/facilitator-name "domains"
368
+    :domains sample-anchor-with-facilitator-with-domain
369
+    sample-anchor-with-facilitator-with-domains
370
+    sample-domain1 sample-domain2 g/remove-role-domain)
371
+
372
+  (should-manipulate-things-in-core-role
373
+    g/facilitator-name "accountabilities"
374
+    :accountabilities sample-anchor-with-facilitator-with-acc
375
+    sample-anchor-with-facilitator-with-accs
376
+    sample-acc1 sample-acc2 g/remove-role-accountability)
377
+
378
+  (should-manipulate-things-in-core-role
379
+    g/rep-link-name "domains"
380
+    :domains sample-anchor-with-rep-link-with-domain
381
+    sample-anchor-with-rep-link-with-domains
382
+    sample-domain1 sample-domain2 g/remove-role-domain)
383
+
384
+  (should-manipulate-things-in-core-role
385
+    g/rep-link-name "accountabilities"
386
+    :accountabilities sample-anchor-with-rep-link-with-acc
387
+    sample-anchor-with-rep-link-with-accs
388
+    sample-acc1 sample-acc2 g/remove-role-accountability)
389
+
390
+  (it "doesn't remove core role when manipulating one collection among many"
391
+    (should= sample-anchor-with-rep-link-with-acc
392
+      (g/remove-role-domain sample-anchor-with-rep-link-with-acc-and-domain
393
+                            g/rep-link-name sample-domain1)))
394
+
395
+  (describe "Adding policies"
396
+    (it "can delegate a predefined domain from Secretary"
397
+      (should=
398
+        (update-in sample-anchor [:roles] assoc g/secretary-name
399
+                   (g/map->Role {:rname    g/secretary-name
400
+                                 :policies sample-policies-secretary}))
401
+        sample-anchor-with-secretary-policy))
402
+
403
+    (it "won't create policies for domains Lead Link doesn't have"
404
+      (should-throw IllegalArgumentException
405
+        "Role 'Secretary' doesn't control domain 'domain it doesn't have'"
406
+        (g/add-role-policy sample-anchor g/secretary-name sample-policy-name
407
+                           sample-policy-text "domain it doesn't have")))
408
+
409
+    (it "can create multiple policies"
410
+      (should=
411
+        (update-in sample-anchor [:roles] assoc g/secretary-name
412
+                   (g/map->Role {:rname g/secretary-name
413
+                                 :policies
414
+                                        (assoc sample-policies-secretary
415
+                                               sample-policy-name2
416
+                                               {:text sample-policy-text2})}))
417
+        sample-anchor-with-secretary-policies)))
418
+
419
+  (describe "removing policies"
420
+    (it "removes Secretary when it is empty"
421
+      (should= sample-anchor
422
+        (g/remove-role-policy sample-anchor-with-secretary-policy
423
+                              g/secretary-name sample-policy-name)))
424
+
425
+    (it "doesn't remove Secretary when it isn't empty"
426
+      (should= sample-anchor-with-secretary-policy
427
+        (g/remove-role-policy sample-anchor-with-secretary-policies
428
+                              g/secretary-name sample-policy-name2)))))
429
+
430
+(def subcircle-name "Development")
431
+(def subcircle-role-name "Programmer")
432
+(def subcircle-role-purpose "Coding")
433
+(def circle-with-subcircle
434
+  (-> sample-anchor
435
+      (g/add-role-to-circle subcircle-name "Great software")
436
+      (g/convert-to-circle subcircle-name)))
437
+(def circle-with-subrole
438
+  (g/update-subcircle circle-with-subcircle [subcircle-name]
439
+                      g/add-role-to-circle role-name
440
+                      subcircle-role-purpose))
441
+
442
+(describe "Subcircle manipulation"
443
+  (it "can add a role to a subcircle"
444
+    (let [expected (update-in circle-with-subcircle [:roles subcircle-name]
445
+                              g/add-role-to-circle subcircle-role-name
446
+                              subcircle-role-purpose)
447
+          actual (g/update-subcircle circle-with-subcircle [subcircle-name]
448
+                                     g/add-role-to-circle subcircle-role-name
449
+                                     subcircle-role-purpose)]
450
+      (should= expected actual)))
451
+
452
+  (it "can remove a role from a subcircle"
453
+    (should= circle-with-subcircle (g/update-subcircle
454
+                                     circle-with-subrole
455
+                                     [subcircle-name] g/remove-role
456
+                                     subcircle-role-name)))
457
+
458
+  (it "can manipulate a deeply-nested structure"
459
+    (let [expected
460
+          (update-in circle-with-subrole [:roles subcircle-name :roles
461
+                                          subcircle-role-name]
462
+                     g/convert-to-circle)
463
+
464
+          actual
465
+          (g/update-subcircle circle-with-subrole [subcircle-name
466
+                                                   subcircle-role-name]
467
+                              g/convert-to-circle)]
468
+      (should= expected actual))))
469
+
470
+(run-specs)

+ 287
- 0
spec/freefrog/governance_roles_spec.clj View File

@@ -0,0 +1,287 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+;;; # Role Manipulation Spec #
21
+;;; Defines how all roles can be manipulated, both through governance
22
+;;; (maintenance and elections) and through the normal business of
23
+;;; appointment/removal.
24
+(ns freefrog.governance-roles-spec
25
+  (:require [clojure.set :as s]
26
+            [freefrog.governance :as g]
27
+            [freefrog.governance-spec-helpers :refer :all]
28
+            [speclj.core :refer :all]))
29
+
30
+(def sample-domain-1 "Code")
31
+(def sample-domain-2 "Tests")
32
+(def sample-domains #{sample-domain-1 sample-domain-2})
33
+(def sample-anchor-with-domain
34
+  (g/add-role-domain sample-anchor-with-role role-name sample-domain-1))
35
+(def sample-anchor-with-domains
36
+  (g/add-role-domain sample-anchor-with-domain role-name sample-domain-2))
37
+(def sample-acc-1 "Writing Code")
38
+(def sample-acc-2 "Testing their own stuff")
39
+(def sample-accountabilities #{sample-acc-1 sample-acc-2})
40
+(def sample-anchor-with-acc
41
+  (g/add-role-accountability sample-anchor-with-role role-name sample-acc-1))
42
+(def sample-anchor-with-accs
43
+  (-> sample-anchor-with-role (g/add-role-accountability role-name sample-acc-1)
44
+      (g/add-role-accountability role-name sample-acc-2)))
45
+
46
+(defn- should-handle-collection-properly [add-fn remove-fn type type-str coll1
47
+                                          coll2 val1 val2]
48
+  (describe type-str
49
+    (it (str "can add a " type-str " to a role with no " type-str "s")
50
+      (should= (update-in sample-anchor-with-role [:roles role-name]
51
+                          assoc type #{val1})
52
+        (add-fn sample-anchor-with-role role-name val1)))
53
+
54
+    (it (str "can add a " type-str " to a role with existing " type-str "s")
55
+      (let [expected
56
+            (update-in coll1 [:roles role-name type] conj val2)]
57
+        (should= expected
58
+          (add-fn coll1 role-name val2))))
59
+
60
+    (it (str "won't add nil to a " type-str)
61
+      (should-throw IllegalArgumentException
62
+        (str type-str " name may not be empty")
63
+        (add-fn sample-anchor-with-role role-name nil)))
64
+
65
+    (should-not-update-missing-or-empty-roles add-fn
66
+      (str "adding a " type-str) val1)
67
+
68
+    (it (str "won't add the same " type-str " twice")
69
+      (should-throw IllegalArgumentException
70
+        (format "%s '%s' already exists on role '%s'" type-str val1 role-name)
71
+        (add-fn coll1 role-name val1)))
72
+
73
+    (it (str "can remove a " type-str " from a role")
74
+      (should= coll1 (remove-fn coll2 role-name val2)))
75
+
76
+    (it (str "removes the " type-str "s array when there are none left")
77
+      (should= sample-anchor-with-role (remove-fn coll1 role-name val1)))
78
+
79
+    (it (str "won't remove a " type-str " that doesn't exist")
80
+      (should-throw IllegalArgumentException
81
+        (format "%s '%s' doesn't exist on role '%s'" type-str val2 role-name)
82
+        (remove-fn coll1 role-name val2)))
83
+
84
+    (should-not-update-missing-or-empty-roles remove-fn
85
+      (str "removing a " type-str) val1)))
86
+
87
+;; Section 3.1.a
88
+(describe "Role Manipulation"
89
+  (describe "adding"
90
+    (it "can add a role to a circle with name and purpose"
91
+      (should (.equals (assoc sample-anchor :roles
92
+                              {role-name
93
+                               (g/map->Role {:rname   role-name
94
+                                             :purpose sample-purpose})})
95
+                       sample-anchor-with-role)))
96
+
97
+    (it "can add a role to a circle that already has roles"
98
+      (let [second-role-name "Tester"
99
+            second-role-purpose "Making sure Programmers don't screw up"]
100
+        (should
101
+          (.equals (update-in sample-anchor-with-role [:roles] assoc
102
+                              second-role-name
103
+                              (g/map->Role {:rname   second-role-name
104
+                                            :purpose second-role-purpose}))
105
+                   (g/add-role-to-circle sample-anchor-with-role
106
+                                         second-role-name
107
+                                         second-role-purpose)))))
108
+
109
+    (it "can add a role to a circle with name and accountabilities"
110
+      (should
111
+        (.equals (assoc sample-anchor :roles
112
+                        {role-name
113
+                         (g/map->Role
114
+                           {:rname            role-name
115
+                            :accountabilities sample-accountabilities})})
116
+                 (g/add-role-to-circle sample-anchor role-name
117
+                                       nil nil sample-accountabilities))))
118
+
119
+    (it "can add a role to a circle with name, purpose, and domains"
120
+      (should
121
+        (.equals (assoc sample-anchor :roles
122
+                        {role-name
123
+                         (g/map->Role {:rname   role-name
124
+                                       :domains sample-domains})})
125
+                 (g/add-role-to-circle sample-anchor role-name nil
126
+                                       sample-domains nil))))
127
+
128
+    (it "can add a role to a circle with name, purpose, and accountabilities"
129
+      (should
130
+        (.equals (assoc sample-anchor :roles
131
+                        {role-name
132
+                         (g/map->Role {:rname   role-name
133
+                                       :domains sample-domains})})
134
+                 (g/add-role-to-circle sample-anchor role-name nil
135
+                                       sample-domains nil))))
136
+
137
+    (it "can add a role to a circle with everything"
138
+      (should (.equals (assoc sample-anchor
139
+                              :roles
140
+                              {role-name
141
+                               (g/map->Role
142
+                                 {:rname            role-name
143
+                                  :purpose          sample-purpose
144
+                                  :domains          sample-domains
145
+                                  :accountabilities sample-accountabilities})})
146
+                       (g/add-role-to-circle sample-anchor role-name
147
+                                             sample-purpose sample-domains
148
+                                             sample-accountabilities))))
149
+
150
+    (it "doesn't let you use empty names"
151
+      (should-throw IllegalArgumentException "Role name may not be empty"
152
+        (g/add-role-to-circle sample-anchor nil nil nil nil))
153
+      (should-throw IllegalArgumentException "Role name may not be empty"
154
+        (g/add-role-to-circle sample-anchor "" nil nil nil)))
155
+
156
+    (it "doesn't let you overwrite an existing role"
157
+      (should-throw IllegalArgumentException (str "Role already exists: "
158
+                                                  role-name)
159
+        (g/add-role-to-circle sample-anchor-with-role role-name nil nil nil))))
160
+
161
+  (describe "removing"
162
+    (it "can remove a role"
163
+      (should= sample-anchor-with-role (-> sample-anchor-with-role
164
+                                           (g/add-role-to-circle "test" "test")
165
+                                           (g/remove-role "test"))))
166
+
167
+    (it "removes the roles array if deleting a role causes it to be empty"
168
+      (should= sample-anchor (g/remove-role sample-anchor-with-role role-name)))
169
+
170
+    (should-not-update-missing-or-empty-roles g/remove-role "role itself"))
171
+
172
+  (def new-name "Code Monkey")
173
+  (describe "updating"
174
+    (describe "name"
175
+      (it "can rename a role"
176
+        (should= (-> sample-anchor-with-role
177
+                     (update-in [:roles] s/rename-keys {role-name new-name})
178
+                     (update-in [:roles new-name] assoc :rname new-name))
179
+
180
+          (g/rename-role sample-anchor-with-role role-name new-name)))
181
+      (should-not-update-missing-or-empty-roles g/rename-role "renaming role"
182
+        new-name))
183
+
184
+    ;; Section 1.1.a
185
+    (describe "purpose"
186
+      (it "can change a role's purpose"
187
+        (let [new-purpose "Building software that's grrreat!"]
188
+          (should= (update-in sample-anchor-with-role [:roles role-name]
189
+                              assoc :purpose new-purpose)
190
+            (g/update-role-purpose sample-anchor-with-role role-name
191
+                                   new-purpose))))
192
+
193
+      (it "can clear a role's purpose"
194
+        (should= (update-in sample-anchor-with-role [:roles role-name] assoc
195
+                            :purpose nil)
196
+          (g/update-role-purpose sample-anchor-with-role role-name nil))
197
+        (should= (update-in sample-anchor-with-role [:roles role-name] assoc
198
+                            :purpose nil)
199
+          (g/update-role-purpose sample-anchor-with-role role-name "")))
200
+
201
+      (should-not-update-missing-or-empty-roles g/update-role-purpose
202
+        "updating purpose" "Stuff"))
203
+
204
+    ;; Section 1.1.b
205
+    (should-handle-collection-properly g/add-role-domain
206
+                                       g/remove-role-domain
207
+                                       :domains "Domain"
208
+                                       sample-anchor-with-domain
209
+                                       sample-anchor-with-domains
210
+                                       sample-domain-1
211
+                                       sample-domain-2)
212
+
213
+    ;; Section 1.1.c
214
+    (should-handle-collection-properly g/add-role-accountability
215
+                                       g/remove-role-accountability
216
+                                       :accountabilities "Accountability"
217
+                                       sample-anchor-with-acc
218
+                                       sample-anchor-with-accs
219
+                                       sample-acc-1
220
+                                       sample-acc-2)))
221
+
222
+(def sample-policy-name "Pull requests")
223
+(def sample-policy-text "You gotta use pull requests to contribute any code.")
224
+(def sample-policy2-name "Straight to Master")
225
+(def sample-policy2-text "Just tell someone what the commit has was.")
226
+(def sample-anchor-with-policy (g/add-role-policy sample-anchor-with-domain
227
+                                                  role-name sample-policy-name
228
+                                                  sample-policy-text))
229
+(def sample-anchor-with-policies (g/add-role-policy sample-anchor-with-policy
230
+                                                    role-name
231
+                                                    sample-policy2-name
232
+                                                    sample-policy2-text))
233
+
234
+;; Section 1.3
235
+(describe "policies"
236
+  (should-not-update-missing-or-empty-roles g/add-role-policy "policy"
237
+    sample-policy-name sample-policy-text)
238
+  (should-not-update-missing-or-empty-roles g/add-role-policy "policy"
239
+    sample-policy-name
240
+    sample-policy-text sample-domain-1)
241
+  (it "can add a policy granting access to all domains"
242
+    (should= (my-add-policy sample-anchor-with-domain role-name
243
+                            sample-policy-name sample-policy-text)
244
+      sample-anchor-with-policy)
245
+    (should= (my-add-policy sample-anchor-with-policy role-name
246
+                            sample-policy2-name sample-policy2-text)
247
+      (g/add-role-policy sample-anchor-with-policy role-name
248
+                         sample-policy2-name sample-policy2-text)))
249
+
250
+  (it "can add a policy granting access to a domain"
251
+    (should= (my-add-policy sample-anchor-with-domain role-name
252
+                            sample-policy-name sample-policy-text
253
+                            sample-domain-1)
254
+      (g/add-role-policy sample-anchor-with-domain role-name
255
+                         sample-policy-name sample-policy-text
256
+                         sample-domain-1)))
257
+  (it (str "won't add a policy granting access to a domain that the role"
258
+           "doesn't control")
259
+    (should-throw IllegalArgumentException
260
+      (format "Role '%s' doesn't control domain '%s'" role-name sample-domain-2)
261
+      (g/add-role-policy sample-anchor-with-domain role-name
262
+                         "Don't test my stuff!" "Only I can test stuff"
263
+                         sample-domain-2)))
264
+  (it "won't add a policy with the same name as one that already exists"
265
+    (should-throw IllegalArgumentException
266
+      (format "Policy '%s' already exists on role '%s'" sample-policy-name
267
+              role-name)
268
+      (g/add-role-policy sample-anchor-with-policy role-name sample-policy-name
269
+                         "More coding stuff!")))
270
+
271
+  (should-not-update-missing-or-empty-roles g/remove-role-policy "policy"
272
+    sample-policy-name)
273
+
274
+  (it "can remove a policy"
275
+    (should= sample-anchor-with-policy
276
+      (g/remove-role-policy sample-anchor-with-policies role-name
277
+                            sample-policy2-name))
278
+    (should= sample-anchor-with-domain
279
+      (g/remove-role-policy sample-anchor-with-policy role-name
280
+                            sample-policy-name)))
281
+  (it "won't remove a policy that doesn't exist"
282
+    (should-throw IllegalArgumentException
283
+      (format "Policy '%s' doesn't exist on role '%s'" sample-policy-name
284
+              role-name)
285
+      (g/remove-role-policy sample-anchor-with-domain role-name
286
+                            sample-policy-name))))
287
+(run-specs)

+ 56
- 0
spec/freefrog/governance_spec_helpers.clj View File

@@ -0,0 +1,56 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+(ns freefrog.governance-spec-helpers
21
+  (:require [freefrog.governance :as g]
22
+            [speclj.core :refer :all]))
23
+
24
+(def sample-anchor (g/create-circle "Amazing Corp"))
25
+(def role-name "Programmer")
26
+(def tester-role "Tester")
27
+
28
+(def sample-purpose "Building awesome software")
29
+(def sample-anchor-with-role (g/add-role-to-circle sample-anchor role-name
30
+                                                   sample-purpose))
31
+(def sample-anchor-with-two-roles
32
+  (g/add-role-to-circle sample-anchor-with-role tester-role))
33
+
34
+(defn my-add-policy
35
+  ([circle name text]
36
+   (update-in circle [:policies]
37
+              assoc name {:text text}))
38
+  ([circle role-name name text]
39
+   (update-in circle [:roles role-name :policies]
40
+              assoc name {:text text}))
41
+  ([circle role-name name text domain]
42
+   (update-in (my-add-policy circle role-name name text)
43
+              [:roles role-name :policies name] assoc :domain domain)))
44
+
45
+(defn should-not-update-missing-or-empty-roles [fn type-str & params]
46
+  (describe (format "%s problems" type-str)
47
+    (it "doesn't work with a role that doesn't exist"
48
+      (should-throw IllegalArgumentException (str "Role not found: "
49
+                                                  role-name)
50
+        (apply fn (concat [sample-anchor role-name] params))))
51
+
52
+    (it "doesn't work with an empty name"
53
+      (should-throw IllegalArgumentException "Role name may not be empty"
54
+        (apply fn (concat [sample-anchor-with-role nil] params)))
55
+      (should-throw IllegalArgumentException "Role name may not be empty"
56
+        (apply fn (concat [sample-anchor-with-role ""] params))))))

+ 12
- 0
spec/freefrog/lang/basic/001_initial_circle.txt View File

@@ -0,0 +1,12 @@
1
+create anchor circle "Courage Labs" with purpose
2
+"General public benefit" and cross-links
3
+"Investor Context Link", "Benefit Context Link", "Environmental Impact Context Link".
4
+
5
+update role "Benefit Context Link" change purpose to "The Organization as a provider of General Public Benefit"
6
+and add accountability "Representing the Benefit Context within the Organization".
7
+
8
+update role "Investor Context Link" change purpose to "The Organization as an effective investment vehicle for its investors"
9
+and add accountability "Representing the Investor Context within the Organization".
10
+
11
+update role "Environmental Impact Context Link" change purpose to "The Organization as a good steward of the Environment"
12
+and add accountability "Representing the Environmental Impact Context within the Organization".

+ 20
- 0
spec/freefrog/lang/basic/002_new_roles.txt View File

@@ -0,0 +1,20 @@
1
+create role "Partner Matters" with purpose
2
+"Bringing in and making Partners happy".
3
+
4
+create role "Accounting" with purpose
5
+"Spending money responsibly" and
6
+domains "Checkbook", "Credit Cards" and
7
+accountabilities
8
+  "Telling people how much money there is to spend",
9
+  "Paying people",
10
+  "Reimbursing for expenses",
11
+  "Depositing income".
12
+
13
+Create Circle "Products" with purpose
14
+"Building cool products to sell" and
15
+Domain "Products" and
16
+Accountabilities
17
+  "Communicating product direction",
18
+  "Gathering customer needs".
19
+
20
+define policy "money" as "you can only spend money on Mondays".

+ 17
- 0
spec/freefrog/lang/basic/003_updating_roles.txt View File

@@ -0,0 +1,17 @@
1
+strike policy "money".
2
+
3
+convert role "Partner Matters" into a circle.
4
+
5
+update circle "Partner Matters" rename to "Partners' Things" and
6
+add domains "Addition of Partners", "Removal of Partners" and
7
+add accountability "Creating policies for addition and removal of partners".
8
+
9
+update circle "Partners' Things"
10
+remove domains "Addition of Partners", "Removal of Partners" and
11
+add domain "Addition/Removal of Partners" and
12
+change purpose to "Ensuring we have the right Partners".
13
+
14
+update circle "Partners' Things" rename to "Partner Matters".
15
+
16
+elect "bill" as facilitator expiring 2014-01-01.
17
+elect "jill" as secretary expiring 2014-01-01.

+ 7
- 0
spec/freefrog/lang/basic/004_updating_subcircles.txt View File

@@ -0,0 +1,7 @@
1
+govern circle "Products".
2
+
3
+create role "Product Analyzer".
4
+
5
+convert role "Product Analyzer" into a circle.
6
+
7
+convert circle "Product Analyzer" into a role.

+ 7
- 0
spec/freefrog/lang/basic/005_role_appointments.txt View File

@@ -0,0 +1,7 @@
1
+appoint "Joe Schmoe" to "Partner Matters" with focus "Contracts".
2
+
3
+appoint "Jill Schmidt" to "Accounting".
4
+
5
+appoint "Larry Badman" to "Partner Matters".
6
+
7
+unappoint "Larry Badman" from "Partner Matters".

+ 26
- 0
spec/freefrog/lang/courage_labs/2015-02-06_adoption.txt View File

@@ -0,0 +1,26 @@
1
+-- At adoption, the following people were Partners by virtue of having
2
+-- ratified the new Operating Agreement:
3
+--   Stephen Starkey
4
+--   Nate Riffe
5
+--   Travis Marsh
6
+--   Steve Mondozzi
7
+
8
+create anchor circle "Courage Labs" with purpose
9
+"General public benefit" and cross-links
10
+"Investor Context Link", "Benefit Context Link",
11
+"Environmental Impact Context Link".
12
+
13
+update role "Benefit Context Link" change purpose to
14
+"The Organization as a provider of General Public Benefit"
15
+and add accountability
16
+"Representing the Benefit Context within the Organization".
17
+
18
+update role "Investor Context Link" change purpose to
19
+"The Organization as an effective investment vehicle for its investors"
20
+and add accountability
21
+"Representing the Investor Context within the Organization".
22
+
23
+update role "Environmental Impact Context Link" change purpose to
24
+"The Organization as a good steward of the Environment"
25
+and add accountability
26
+"Representing the Environmental Impact Context within the Organization".

+ 42
- 0
spec/freefrog/lang/courage_labs/2015-04-15_anchor_circle.txt View File

@@ -0,0 +1,42 @@
1
+-- This initial meeting began with the election for the three cross-links
2
+-- defined in the Operating Agreement:
3
+
4
+appoint "Stephen Starkey" to "Benefit Context Link" with focus
5
+"Expires 2017-04-18".
6
+
7
+appoint "Nate Riffe" to "Environmental Impact Context Link" with focus
8
+"Expires 2017-04-18".
9
+
10
+appoint "Steve Mondozzi" to "Investor Context Link" with focus
11
+"Expires 2017-04-18".
12
+
13
+create role "Software Tools" with purpose
14
+"Coaching the world with Software Tools" and domain "Software".
15
+
16
+-- We also appointed Stephen Starkey, Nate Riffe, and Travis Marsh to the
17
+-- "Software Tools" role as an operational decision.
18
+
19
+create role "Coaching People" with purpose
20
+"Providing coaching services to individuals"
21
+and domain "Coaching Services".
22
+
23
+appoint "Stephen Starkey" to "Coaching People".
24
+appoint "Travis Marsh" to "Coaching People".
25
+
26
+define policy "Income from Services" as
27
+"Services income is moved to the service provider's account less a 5% fee
28
+ for expenses.".
29
+
30
+create role "Money Matters" with purpose "Handling Courage Labs' Money"
31
+and domain "Financial accounts" and accountabilities
32
+"Reimbursing Members for expenses",
33
+"Establishing mechanisms by which Members can contribute income".
34
+
35
+elect "Travis Marsh" as Secretary expiring 2015-10-18.
36
+elect "Stephen Starkey" as Facilitator expiring 2015-10-18.
37
+
38
+appoint "Stephen Starkey" to "Money Matters".
39
+appoint "Steve Mondozzi" to "Money Matters".
40
+
41
+define policy "Expenses" as "Member expenses by default come out of
42
+that Member's account.".

+ 77
- 0
spec/freefrog/lang/courage_labs/2015-04-22_anchor_circle.txt View File

@@ -0,0 +1,77 @@
1
+update role "Money Matters" change purpose to
2
+"Responsible handling of Courage Labs' money" and
3
+remove accountability
4
+"Establishing mechanisms by which Members can contribute income" and
5
+add accountability
6
+"Establishing mechanisms by which Partners can contribute income" and
7
+add accountability
8
+"Maintaining a budget accessible to all Partners that they can view and change themselves"
9
+and add accountability
10
+"Reviewing the budget quarterly and notifying Partners of any risk and potential mitigation strategies"
11
+and add domain "Budget".
12
+
13
+create role "Taxes" with purpose "Keeping us square with the government" and
14
+accountabilities "Paying taxes on income",
15
+"Filing taxes before the corporate deadline",
16
+"Sending K-1 statements in time for Partners to file their taxes" and
17
+domain "Taxes".
18
+
19
+create role "Spokesperson" with purpose "Engagement with the outside world" and
20
+accountabilities "Keeping the website up-to-date with what we're doing",
21
+"Posting to the blog when we do cool stuff",
22
+"Routing requests from the outside world to the appropriate Role(s)",
23
+"Reminding Partners what our story is so they can communicate it properly"
24
+and domain "All non-personal external communications media".
25
+
26
+update role "Spokesperson" rename to "Ambassador".
27
+
28
+convert role "Software Tools" into a circle.
29
+
30
+update circle "Software Tools" add accountability
31
+"Producing a governance tool that Courage Labs can use in place of Glassfrog".
32
+
33
+strike policy "Income from Services".
34
+
35
+define policy "Income Generated By Partners" as
36
+"If a Partner creates a flow of income, they may decide how that income is
37
+allocated to Member accounts, less a 5% fee for Organization expenses.".
38
+
39
+define policy "Organizational Expenses" as
40
+"Any member may spend any money for organizational purposes on a one-time or
41
+recurring manner, so long as:
42
+ 1. They review the existing budget,
43
+ 2. They add a line item for their expense to the budget,
44
+ 3. Adding the line item won't cause the Organization to run out of money in the
45
+    next year, and
46
+ 4. They notify the company that the new expense has been added.".
47
+
48
+strike policy "Expenses".
49
+
50
+define policy "Partner Expenses" as
51
+"Any Partner may spend any money in their own account to further any of their
52
+existing Roles so long as doing so won't jeopardize any existing
53
+organization-wide budget line item or cause their Member Account Balance to
54
+go below zero.".
55
+
56
+define policy "Governance Outside of Meetings" as
57
+"Any governance proposal in any Circle made via the mechanism specified in
58
+section 3.4 of the Constitution is automatically adopted as formal governance if:
59
+ 1. The proposal is emailed to all Circle Members at their Courage Labs
60
+    e-mail account, and
61
+ 2. That Circle's Secretary doesn't receive a response with any Objections
62
+    within 96 hours.".
63
+
64
+define policy "Income Generated By Circles" as
65
+"If a Circle creates a flow of income, it may decide how that income is
66
+allocated to Member accounts in its Governance meeting, less a 5% fee for
67
+Organization expenses.".
68
+
69
+-- Other outcomes that aren't actual governance:
70
+--
71
+-- Invite Bill Finn to be a partner
72
+-- The Operating Agreement is back-dated to January 1, 2015
73
+-- Strategy is changed to: Prefer projects that generate income.  Of those
74
+--   projects prefer generating income through passive means over generating
75
+--   income through direct means
76
+
77
+appoint "Steve Mondozzi" to "Taxes".

+ 11
- 0
spec/freefrog/lang/courage_labs/2015-04-22_software_tools_circle.txt View File

@@ -0,0 +1,11 @@
1
+govern circle "Software Tools".
2
+
3
+appoint "Stephen Starkey" to "Lead Link".
4
+
5
+create role "Income" with purpose
6
+"Generating income from our software tools".
7
+
8
+create role "Builder" with purpose
9
+"Building software" and domain "Software" and accountability
10
+"Demonstrating progress building software tools to coach the world at least monthly.".
11
+

+ 2
- 0
spec/freefrog/lang/courage_labs/2015-05-09_anchor_circle.txt View File

@@ -0,0 +1,2 @@
1
+appoint "Travis Marsh" to "Ambassador".
2
+appoint "Stephen Starkey" to "Ambassador".

+ 5
- 0
spec/freefrog/lang/courage_labs/2015-05-10a_software_tools_circle.txt View File

@@ -0,0 +1,5 @@
1
+govern circle "Software Tools".
2
+
3
+elect "Bill Finn" as rep link expiring 2015-11-10.
4
+elect "Bill Finn" as facilitator expiring 2015-11-10.
5
+elect "Travis Marsh" as secretary expiring 2015-11-10.

+ 8
- 0
spec/freefrog/lang/courage_labs/2015-05-10b_software_tools_circle.txt View File

@@ -0,0 +1,8 @@
1
+govern circle "Software Tools".
2
+
3
+create role "Code Retreat Host" with purpose "Spectacular code retreats".
4
+
5
+create role "Product Manager" with purpose
6
+"Good decision making about product direction" and accountabilities
7
+"Generating and maintaining the software product roadmap based on market research",
8
+"Soliciting feedback from inside and outside Courage Labs about the direction of the product".

+ 4
- 0
spec/freefrog/lang/courage_labs/2015-05-16_software_tools.txt View File

@@ -0,0 +1,4 @@
1
+govern circle "Software Tools".
2
+
3
+elect "George Shakhnazaryan" as rep link expiring 2016-04-26.
4
+elect "Travis Marsh" as secretary expiring 2016-05-16.

+ 1
- 0
spec/freefrog/lang/courage_labs/2015-06-11_anchor_circle.txt View File

@@ -0,0 +1 @@
1
+delete role "Coaching People".

+ 12
- 0
spec/freefrog/lang/courage_labs/2015-06-20_anchor_circle.txt View File

@@ -0,0 +1,12 @@
1
+create role "Infrastructure" with purpose
2
+"Providing a working IT infrastructure for Courage Labs" and domain
3
+"Infrastructure".
4
+
5
+update role "Taxes" rename to "Government Point Person" and
6
+add accountability "Filing LLC renewals on time" and
7
+add domain "Government Interaction".
8
+
9
+update circle "Software Tools" add accountability
10
+"Producing products that coach the world and generate income.".
11
+
12
+unappoint "Stephen Starkey" from "Money Matters".

+ 3
- 0
spec/freefrog/lang/courage_labs/2015-07-23_anchor_circle.txt View File

@@ -0,0 +1,3 @@
1
+unappoint "Nate Riffe" from "Environmental Impact Context Link".
2
+appoint "Jamé Corrar" to "Environmental Impact Context Link" with focus
3
+"Expires 2017-07-23".

+ 17
- 0
spec/freefrog/lang/courage_labs/2015-07-23_software_tools_circle.txt View File

@@ -0,0 +1,17 @@
1
+govern circle "Software Tools".
2
+
3
+update role "Builder" remove accountability
4
+"Demonstrating progress building software tools to coach the world at least monthly."
5
+and add accountability
6
+"Demonstrating progress building software tools to coach the world at least weekly.".
7
+
8
+-- This is a catch-up segment since Glassfrog doesn't track role appointments
9
+appoint "Bill Finn" to "Builder".
10
+appoint "Stephen Starkey" to "Builder".
11
+appoint "Travis Marsh" to "Builder".
12
+
13
+appoint "Stephen Starkey" to "Code Retreat Host".
14
+
15
+appoint "Travis Marsh" to "Income".
16
+
17
+appoint "Jamé Corrar" to "Product Manager".

+ 7
- 0
spec/freefrog/lang/courage_labs/2015-10-26_software_tools_circle.txt View File

@@ -0,0 +1,7 @@
1
+govern circle "Software Tools".
2
+
3
+elect "Travis Marsh" as facilitator expiring 2016-10-26.
4
+
5
+define policy "Open Source Contributions" as
6
+"Any partner in the Software Tools role may allow any outside contributor
7
+ commit access to specific projects.".

+ 11
- 0
spec/freefrog/lang/courage_labs/2016-01-01_anchor_circle.txt View File

@@ -0,0 +1,11 @@
1
+define policy "Partner Removal" as
2
+"No partner may be removed without having received 1 month's notice of the
3
+ tension to be raised to potentially remove them.".
4
+
5
+create role "Partner Membership"
6
+with purpose "Keeping us motivated to participate."
7
+and domain "Criteria for Partner Membership"
8
+and accountabilities
9
+"Asking advice from all existing partners before changing any of the criteria
10
+ for membership.",
11
+"Defining criteria for acceptance to and removal from membership.".

+ 10
- 0
spec/freefrog/lang/courage_labs/2016-01-01_partner_membership.txt View File

@@ -0,0 +1,10 @@
1
+govern role "Partner Membership".
2
+
3
+define policy "Criteria for Partner Membership" as
4
+"** Admission to Membership **
5
+Any person may be admitted to Membership if one of the following two criteria
6
+are met:
7
+1. The Lead Link of a Circle has determined the person would be a good fit for a defined Role, or
8
+2. The GCC has determined the person would be a good fit for a defined Role.
9
+** Removal from Membership **
10
+Any person may be removed from Membership if they are not filling any Roles.".

+ 4
- 0
spec/freefrog/lang/multiple-subcircle-governance.txt View File

@@ -0,0 +1,4 @@
1
+govern circle "Products".
2
+create role "Developer".
3
+govern circle "Partner Matters".
4
+create role "Partner Admission".

+ 168
- 0
spec/freefrog/lang_spec.clj View File

@@ -0,0 +1,168 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+(ns freefrog.lang-spec
21
+  (:require [clj-yaml.core :as yaml]
22
+            [clj-time.core :as t]
23
+            [freefrog.governance :as g]
24
+            [freefrog.lang :as l]
25
+            [speclj.core :refer :all])
26
+  (:import (freefrog GovernanceParseException)))
27
+
28
+;; Monkey patch clj-yaml to do nice encoding of dates and defrecords
29
+(ns clj-yaml.core
30
+  (:require [clj-time.format :as f]))
31
+
32
+(defn encode-without-nils [data]
33
+  (encode (into {} (remove (comp nil? second) data))))
34
+
35
+(extend-protocol YAMLCodec
36
+  freefrog.governance.Role
37
+  (encode [data] (encode-without-nils data))
38
+
39
+  freefrog.governance.Circle
40
+  (encode [data] (encode-without-nils data))
41
+
42
+  org.joda.time.DateTime
43
+  (encode [data]
44
+    (f/unparse (f/formatters :date) data)))
45
+
46
+(ns freefrog.lang-spec)
47
+
48
+(defn governance [name]
49
+  (slurp (str "spec/freefrog/lang/" name "-governance.txt")))
50
+
51
+(def sample-anchor-circle (g/create-circle "Courage Labs"))
52
+
53
+(def expiration-date (t/date-time 2014 01 01))
54
+
55
+(def very-governed-circle
56
+  (-> sample-anchor-circle
57
+      (g/add-role-to-circle "Benefit Context Link"
58
+                            (str "The Organization as a provider of General "
59
+                                 "Public Benefit")
60
+                            nil
61
+                            #{(str "Representing the Benefit Context within"
62
+                                   " the Organization")})
63
+      (g/add-role-to-circle "Investor Context Link"
64
+                            (str "The Organization as an effective investment "
65
+                                 "vehicle for its investors")
66
+                            nil
67
+                            #{(str "Representing the Investor Context within "
68
+                                   "the Organization")})
69
+      (g/add-role-to-circle "Environmental Impact Context Link"
70
+                            (str "The Organization as a good steward of the "
71
+                                 "Environment")
72
+                            nil
73
+                            #{(str "Representing the Environmental Impact "
74
+                                   "Context within the Organization")})
75
+      (g/update-purpose "General public benefit")
76
+      (g/add-role-to-circle "Partner Matters"
77
+                            "Bringing in and making Partners happy")
78
+      (g/appoint-to-role "Partner Matters" "Joe Schmoe" "Contracts")
79
+      (g/add-role-to-circle "Accounting"
80
+                            "Spending money responsibly"
81
+                            ["Checkbook", "Credit Cards"]
82
+                            ["Telling people how much money there is to spend"
83
+                             "Paying people"
84
+                             "Reimbursing for expenses"
85
+                             "Depositing income"])
86
+      (g/appoint-to-role "Accounting" "Jill Schmidt")
87
+      (g/add-role-to-circle "Products"
88
+                            "Building cool products to sell"
89
+                            ["Products"]
90
+                            ["Communicating product direction"
91
+                             "Gathering customer needs"])
92
+      (g/convert-to-circle "Products")
93
+      (g/convert-to-circle "Partner Matters")
94
+      (g/update-role-purpose "Partner Matters"
95
+                             "Ensuring we have the right Partners")
96
+      (g/add-role-domain "Partner Matters" "Addition/Removal of Partners")
97
+      (g/add-role-accountability
98
+        "Partner Matters"
99
+        "Creating policies for addition and removal of partners")
100
+      (g/elect-to-role g/facilitator-name "bill" expiration-date)
101
+      (g/elect-to-role g/secretary-name "jill" expiration-date)
102
+      (g/update-subcircle ["Products"] g/add-role
103
+                          (g/map->Role {:rname "Product Analyzer"}))))
104
+
105
+(describe "Parsing governance"
106
+  (it "should ignore comments"
107
+    (should= () (l/parse-governance "--this is fun\n")))
108
+
109
+  (it "should allow double quotes in comments"
110
+    (should= () (l/parse-governance "--this is fun \"stuff\"\n"))))
111
+
112
+(describe "Executing governance documents"
113
+  (it "should throw nice errors for bad parsing"
114
+    (should-throw GovernanceParseException
115
+      (str "Parse error at line 1, column 32:\nconvert role \"Partner "
116
+           "Matters\" to a circle.\n                               ^\n"
117
+           "Expected:\n\"into a\"\n")
118
+      (l/execute-governance "convert role \"Partner Matters\" to a circle.")))
119
+
120
+  (it "should be able to create a new anchor circle without crosslinks"
121
+    (should= (g/create-circle "Courage Labs")
122
+      (l/execute-governance "CREATE ANCHOR CIRCLE \"Courage Labs\".")))
123
+
124
+  (it "should be able to create a new anchor with special characters"
125
+    (should= (g/create-circle "Courage & Labs!@#$%^&*()")
126
+      (l/execute-governance
127
+        "CREATE ANCHOR CIRCLE \"Courage & Labs!@#$%^&*()\".")))
128
+
129
+  (it "should not allow nonsense in role/circle conversions"
130
+    (should-throw GovernanceParseException
131
+      "Cannot convert circle into a circle."
132
+      (clojure.pprint/pprint
133
+        (l/execute-governance
134
+          (str "create anchor circle \"place\".\n"
135
+               "create role \"Thing\" with purpose \"stuff\".\n"
136
+               "convert role \"Thing\" into a circle.\n"
137
+               "convert circle \"Thing\" into a circle.\n"))))
138
+
139
+    (should-throw GovernanceParseException
140
+      "Cannot convert role into a role."
141
+      (clojure.pprint/pprint
142
+        (l/execute-governance
143
+          (str "create anchor circle \"place\".\n"
144
+               "create role \"Thing\" with purpose \"stuff\".\n"
145
+               "convert role \"Thing\" into a role.\n")))))
146
+
147
+  (it "should do all the governance"
148
+    (should= very-governed-circle
149
+      (l/execute-directory "spec/freefrog/lang/basic")))
150
+
151
+  (describe "governing subcircles"
152
+    (it "won't allow multiple subcircles to be governed in one document"
153
+      (should-throw GovernanceParseException
154
+        #"Parse error at line 3, column 1:\ngovern circle \"Partner Matters\".*"
155
+        (l/execute-governance
156
+          sample-anchor-circle
157
+          (governance "multiple-subcircle"))))
158
+    (it "won't allow subcircle governance except as the first statement"
159
+      (should-throw GovernanceParseException
160
+        #"Parse error at line 2, column 1:\ngovern circle \"stuff\".*"
161
+        (l/execute-governance
162
+          sample-anchor-circle
163
+          "create role \"things\".\ngovern circle \"stuff\".\n"))))
164
+
165
+  (describe "Courage Labs Governance smoke test"
166
+    (with-all result (l/execute-directory "spec/freefrog/lang/courage_labs"))
167
+    (it "should be able to execute all Courage Labs Governance"
168
+      (println (yaml/generate-string @result)))))

+ 68
- 0
spec/freefrog/render_spec.clj View File

@@ -0,0 +1,68 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+(ns freefrog.render-spec
21
+  (:require [freefrog.governance :as g]
22
+            [freefrog.render :as render]
23
+            [speclj.core :refer :all]
24
+            [clj-time.core :as t]))
25
+
26
+(def simple-circle (-> (g/create-circle "simple circle")
27
+                       (g/update-purpose "Simplicity")
28
+                       (g/add-role-to-circle "role 1" "rocking")
29
+                       (g/add-role-accountability "role 1" "doing basic things")
30
+                       (g/add-role-to-circle "role 2" "being #2"
31
+                                             ["dom1" "dom2"]
32
+                                             ["acc1" "acc2"])
33
+                       (g/add-policy "basic policy" "you can do things")
34
+                       (g/add-role-policy "role 2" "basic role policy"
35
+                                          "you also can do things")
36
+                       (g/add-role-to-circle "role 3")
37
+                       (g/add-role-accountability "role 3"
38
+                                                  "other basic things")
39
+                       (g/appoint-to-role "role 2" "larry")
40
+                       (g/appoint-to-role "role 2" "george" "some stuff")
41
+                       (g/elect-to-role g/facilitator-name "phil"
42
+                                        (t/date-time 2014 01 01))
43
+                       (g/elect-to-role g/secretary-name "larry"
44
+                                        (t/date-time 2014 01 01))
45
+                       (g/convert-to-circle "role 3")
46
+                       (g/update-subcircle ["role 3"] g/add-role-to-circle
47
+                                           "test")))
48
+
49
+(describe "Simple circle"
50
+  (it "should render the basics of a circle"
51
+    (should= "# simple circle #\nSimplicity\n
52
+Facilitator: phil, expiring 2014-01-01
53
+Secretary: larry, expiring 2014-01-01\n
54
+## Policies ##\n\n  0. basic policy\n
55
+## Roles ##\n\n  0. role 1\n  1. role 2\n  2. role 3\n"
56
+      (render/markdown-role simple-circle))
57
+    (should= "# role 1 #\nrocking\n
58
+## Accountabilities ##\n\n  * doing basic things\n"
59
+      (render/markdown-role (g/get-role simple-circle "role 1")))
60
+    (should=
61
+      "# role 2 #\nbeing #2\n\n## Domains ##\n\n  * dom1\n  * dom2\n
62
+## Accountabilities ##\n\n  * acc1\n  * acc2\n\n## Policies ##\n
63
+  0. basic role policy\n\n## Assignees ##\n
64
+  * larry\n  * george, for some stuff \n"
65
+      (render/markdown-role (g/get-role simple-circle "role 2")))
66
+    (should= "# role 3 #\n\n## Accountabilities ##\n\n  * other basic things\n
67
+## Roles ##\n\n  0. test\n"
68
+      (render/markdown-role (g/get-role simple-circle "role 3")))))

+ 112
- 0
src/clj/freefrog/cli.clj View File

@@ -0,0 +1,112 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+(ns freefrog.cli
21
+  (:require [clojure.string :as str]
22
+            [clojure.tools.cli :as cli]
23
+            [clojure.walk :as walk]
24
+            [freefrog.governance :as g]
25
+            [freefrog.lang :as l]
26
+            [freefrog.render :as render])
27
+  (:gen-class))
28
+
29
+(def cli-options
30
+  [["-d" "--dir DIR" "Directory of governance documents"
31
+    :id :dir]
32
+   ["-h" "--help"]])
33
+
34
+(defn- select-circle [anchor-circle circle-path]
35
+  (update-in (if (seq circle-path)
36
+               (get-in anchor-circle (g/path-to-role circle-path))
37
+               anchor-circle)
38
+             [:roles]
39
+             #(walk/postwalk (fn [thing]
40
+                               (if (satisfies? g/RoleContainer thing)
41
+                                 (dissoc thing :roles)
42
+                                 thing)) %)))
43
+
44
+(def path (atom []))
45
+(def command (atom ""))
46
+
47
+(defn interpret-command! [anchor-circle]
48
+  (let [c @command]
49
+    (cond
50
+      (.startsWith c "r")
51
+      (let [idx (Integer/valueOf (subs c 1))
52
+            current-path @path
53
+
54
+            circle-to-introspect
55
+            (get-in anchor-circle (g/path-to-role current-path))
56
+
57
+            rendered-circle
58
+            (render/reduce-to-names-with-indices circle-to-introspect :roles)
59
+
60
+            role (-> rendered-circle
61
+                     :roles
62
+                     (nth idx)
63
+                     :name)]
64
+        (swap! path conj role)
65
+        nil)
66
+
67
+      (.startsWith c "p")
68
+      (let [idx (Integer/valueOf (subs c 1))
69
+            current-path @path
70
+
71
+            circle-to-introspect
72
+            (get-in anchor-circle (g/path-to-role current-path))
73
+
74
+            rendered-circle
75
+            (render/make-role-renderable circle-to-introspect)
76
+
77
+            policy (-> rendered-circle
78
+                     :policies
79
+                     (nth idx)
80
+                     :name)]
81
+
82
+        (get-in circle-to-introspect [:policies policy :text]))
83
+
84
+      (= ".." c) (do (swap! path pop) nil)
85
+      (= "/" c) (do (reset! path []) nil)
86
+      (= "?" c) (str
87
+                  "====\n"
88
+                  "help\n"
89
+                  "====\n"
90
+                  "..\tUp one\n"
91
+                  "/\tBack to Anchor\n"
92
+                  "r##\tDescend to role indicated by index\n\n"))))
93
+
94
+(defn -main [& args]
95
+  (let [{:keys [options arguments errors summary]}
96
+        (cli/parse-opts args cli-options)
97
+
98
+        {:keys [dir]} options]
99
+    (while true
100
+      (try
101
+        (let [anchor-circle (l/execute-directory dir)
102
+              extra-text (interpret-command! anchor-circle)
103
+              selected-circle (select-circle anchor-circle @path)]
104
+          (println (if extra-text extra-text
105
+                                  (render/markdown-role selected-circle))))
106
+
107
+        (catch Throwable t
108
+          (.printStackTrace t))
109
+        (finally (print (str (str/join "/" @path) ": "))
110
+                 (flush)
111
+                 (let [entry (read-line)]
112
+                   (reset! command entry)))))))

+ 110
- 0
src/clj/freefrog/core_roles.clj View File

@@ -0,0 +1,110 @@
1
+;
2
+; Copyright © 2015 Courage Labs
3
+;
4
+; This file is part of Freefrog.
5
+;
6
+; Freefrog is free software: you can redistribute it and/or modify
7
+; it under the terms of the GNU Affero General Public License as published by
8
+; the Free Software Foundation, either version 3 of the License, or
9
+; (at your option) any later version.
10
+;
11
+; Freefrog is distributed in the hope that it will be useful,
12
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+; GNU Affero General Public License for more details.
15
+;
16
+; You should have received a copy of the GNU Affero General Public License
17
+; along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
+;
19
+
20
+;;; ### These are the core rules defined in the Holacracy Constitution ###
21
+(ns freefrog.core-roles
22
+  (:require [freefrog.governance :as g]))
23
+
24
+(def lead-link
25
+  (g/map->Role
26
+    {:rname g/lead-link-name
27
+     :purpose
28
+            (str "The Lead Link Role shall be deemed to hold the purpose of "
29
+                 "the overall Circle.")
30
+     :domains
31
+            [(get g/core-role-domains g/lead-link-name)]
32
+     :accountabilities
33
+            [(str "Differentiating and organizing the Circle's overall work "
34
+                  "into segmented Roles and other requisite Governance")
35
+             (str "Assigning Partners to the Circle's Roles, monitoring fit "
36
+                  "between Partners and their Roles and offering feedback to "
37
+                  "enhance fit, and removing Partners from Roles when useful")
38
+             (str "Allocating the Circle's available resources across its "
39
+                  "various Projects and/or Roles")
40
+             "Assessing and defining priorities and Strategies for the Circle"
41
+             (str "Defining and assigning metrics within the Circle that "
42
+                  "provide visibility into such Circle's expression of its "
43
+                  "Purpose and enactment of its Accountabilities")]}))
44
+
45
+(def rep-link
46
+  (g/map->Role
47
+    {:rname g/rep-link-name
48
+     :purpose
49
+            (str "Within the Super-Circle, the Rep Link Role shall be deemed "
50
+                 "to hold the purpose of the overall Circle so represented; "
51
+                 "within such Circle, the Rep Link Role's Purpose shall be: "
52
+                 "Tensions relevant to process in the Super-Circle channeled "
53
+                 "out and resolved.")