Skip to content

About

Municipal contract templates in Accord Project format (Concerto + TemplateMark) with Clojure logic

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

TrustBlocks templates

Municipal contract templates in Accord Project's format — Concerto models, TemplateMark text — with their executable logic written in Clojure.

Each template is a real contract: the Town of China Grove, North Carolina's own documents, modelled so the text can be drafted from data and the contract's clauses can run. They build into standard .cta archives that Accord Project's own tools load and draft, and that Trustblocks runs.

Template What it is Logic
manager-employment-contract The Town Manager's employment contract (2025–2029, restated): council approval, severance, service-credit purchase Lifecycle: Board approval certified by the Town Clerk, then attestations. Clause: records the approval and effective date

Packages

A package is a family of templates for the documents of one kind of matter: the contract, and the documents made under it, each its own template and its own archive. In Trustblocks a matter is one live instance of a package.

Package Template What it is Logic / lifecycle
street-resurfacing contract Contract No. STR-27, a formally bid unit-price street resurfacing contract: 37 pay items, statutory retainage, liquidated damages Not yet
pay-application Exhibit "E"'s Contractor Pay Request, with a schedule of pay items (Completed / Approved by Engineer) and a Finance Officer's payment certificate Lifecycle: received → inspected → certified → approved → paid, each step certified. Clause: records the engineer's approvals; refuses certification of unapproved work or figures that do not agree

Layout

templates/<name>/          one Accord template directory each
  package.json             Accord metadata, plus a "trustblocks" section for executing templates
  model/*.cto              Concerto models, with every import vendored beside them
  text/grammar.tem.md      TemplateMark (CommonMark + pipe tables)
  sample.json              a contract instance to draft from
  logic/clause.clj         the clause, for templates that execute
  lifecycle.json           the document's states and certified events, for templates that have one
  request.json             a request the clause answers, for templates that execute
packages/<package>/
  README.md                the package: its documents and how they relate
  manifest.edn             what a matter made from it consists of -- see docs/manifest.md
  templates/<name>/        one Accord template directory per document type, laid out as above
shared/model/              canonical copies of models more than one template carries
sources/                   the source documents templates were derived from
docs/                      model conventions; what Accord's engine actually requires

Clojure logic in an Accord archive

Accord's tools accept only es6 or typescript as a template's accordproject.runtime, and refuse to load an archive declaring anything else. So every template here keeps an Accord-valid runtime there — which is what lets Accord's tools load and draft it — and a template whose logic is Clojure says so in a section of its own that Accord ignores:

"accordproject": { "runtime": "typescript", "template": "contract", "cicero": "^2.0.0" },
"trustblocks":   { "runtime": "clojure", "logic": "logic/clause.clj" }

In Accord Project's tools such an archive drafts, validates, and shows its model; Trustblocks runs its logic.

The same section names a template's lifecycle, when it has one -- see docs/model-conventions.md:

"trustblocks": { "lifecycle": "lifecycle.json" }

A lifecycle's events are the template's own Request types, or the shared AttestationRequest for attestations to the contract -- the manager contract's lifecycle requires the Town Clerk's CERTIFY_MINUTES for both its Board approval and any attestation after it.

logic/clause.clj is one expression — the clause — evaluated in Trustblocks' sandbox with four bindings: data (the contract), request, state (the contract's state as of the request's own time, or nil), and now (when the request takes effect, as an ISO-8601 string). It returns {:response ...}, and :state ... when the contract's state changes, both Concerto instances; it refuses by throwing. There is no clock, I/O or interop in the sandbox, so a clause's answer depends only on its inputs and an execution can be replayed.

The sandbox is in this repository: runtime/ holds the clause vocabulary, the lifecycle and the step the Trustblocks app takes on every request -- the same code, compiled to trustblocks-logic.js, runs a template's logic in the browser, with the same answer to the character.

Checking and building

Needs babashka; bb conformance also needs Node.

bb check          # structure, logic, shared-model copies, CommonMark rules
bb build          # dist/<name>@<version>.cta for every template
npm install       # once, for the Accord reference toolchain
bb conformance    # every template, and every built archive, drafts through Accord's engine

# The clause runtime -- needs the Clojure CLI too
bb runtime-test   # its JVM tests, the parity fixture included
bb cljs-test      # the parity test, compiled to ClojureScript, under Node
bb logic-bundle   # target/trustblocks-logic.js, tested as the browser loads it

Using the templates from Clojure

deps.edn puts templates/ and packages/ on the classpath, so a template is a resource under its own name, and a package's under <package>/templates/<name> -- and runtime/src, so the runtime is com.trustblocks.clause, com.trustblocks.lifecycle and com.trustblocks.runtime:

io.github.TrustBlocks/trustblocks-templates {:git/sha "..."}

(clojure.java.io/resource "manager-employment-contract/package.json")
(clojure.java.io/resource "street-resurfacing/templates/pay-application/package.json")

See docs/model-conventions.md for namespaces and how shared models are reused, and docs/templatemark-conformance.md for what Accord's engine actually requires of a template.

About

Municipal contract templates in Accord Project format (Concerto + TemplateMark) with Clojure logic

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages