Skip to content

feat(agreement): compose executable clauses into one tree of instances - #205

Draft
mttrbrts wants to merge 1 commit into
claude/agreement-1.0-north-starfrom
claude/agreement-1.0-composition
Draft

mttrbrts wants to merge 1 commit into
claude/agreement-1.0-north-starfrom
claude/agreement-1.0-composition

Conversation

@mttrbrts

@mttrbrts mttrbrts commented Oct 1, 2026

Copy link
Copy Markdown
Member

Stacked on #200. This folds "design B", prototyped in accordproject/cicero-template-library#528, into the 1.0.0 namespaces. A composed clause becomes a template instance in its own right. A document and its composed clauses then form one tree, with one state index, so logic can run embedded clauses and commit their state atomically with the document's.

Changes

  • agreement@1.0.0:
    • Clause carries its own data (its TemplateData subtype) and its own composed clauses.
    • clauseId is now required: it's the clause's stable instance id.
    • The path docs now cover clauses composed into clauses (keys joined with /).
    • AgreementReference gains documentId, since a clause path is only unique within a document.
  • runtime@1.0.0: AgreementState replaces data and clauseStates with states, a map keyed by instance id (a document's documentId or a clause's clauseId). Stateless instances have no entry, and the index doesn't mirror the tree's shape. The map is renamed from ClauseStates to InstanceStates.
  • obligation@1.0.0: adds event ObligationIssued { o Obligation obligation }, so logic issues an obligation by emitting an event, just as it changes one with ObligationTransition.

Flags

  • Breaking changes inside feat(agreement): 1.0 agreement, party and runtime models #200's unpublished 1.0.0 files:
    • Clause.clauseId and Clause.data become required.
    • AgreementState.data and AgreementState.clauseStates are removed.
    • These are acceptable only because 1.0.0 isn't published yet.
  • Validation: checked by loading all 1.0.0 namespaces (plus settlement) into one Concerto 5.0.0 ModelManager. Clauses nested two deep, a states index and a reference with documentId all validate. The repo has no test suite, and build.js resolves imports over HTTP from the live site, which can't serve these until they're published.
  • Consumers: template-engine and cicero-core changes, and the migrated sample template, follow in separate PRs.

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to master from fork:branchname

🤖 Generated with Claude Code

https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS


Generated by Claude Code

Make a composed clause a template instance in its own right, so an
agreement's documents and the clauses composed into them form one tree
with one state index:

- agreement@1.0.0: Clause carries its own data and composed clauses,
  and a required clauseId (its stable instance id).
  AgreementReference gains documentId, since a clause path is only
  unique within a document.
- runtime@1.0.0: AgreementState replaces data and clauseStates with a
  states map keyed by instance id (documentId or clauseId). Stateless
  instances have no entry.
- obligation@1.0.0: add ObligationIssued, so logic issues an
  obligation by emitting an event, as it changes one with
  ObligationTransition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
Signed-off-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🧩 Concerto Playground Preview

The .cto model changes in this PR are pre-loaded into the Concerto Playground — click a link below for a live preview.

File Preview
src/accordproject/agreement@1.0.0.cto Diagram · Code · Open in Playground
src/accordproject/obligation@1.0.0.cto Diagram · Code · Open in Playground
src/accordproject/runtime@1.0.0.cto Diagram · Code · Open in Playground

All 3 changed models together: Preview combined

Auto-generated from commit 0564c23. Updates automatically on new commits.

mttrbrts pushed a commit to accordproject/cicero-template-library that referenced this pull request Oct 1, 2026
… API, as three templates

The prototype's local runtime is replaced by the released shape of the
design:

- Models: the 1.0.0 namespaces are refreshed from accordproject/models#205,
  which folds the prototype's proposal namespace (composition.cto) into
  agreement@1.0.0 (Clause with data and clauses, AgreementReference with a
  documentId), runtime@1.0.0 (AgreementState.states) and obligation@1.0.0
  (ObligationIssued). composition.cto is removed.
- Templates: the composed late payment clause and the licensed work
  schedule become sibling templates, late-payment-poc and
  licensed-work-schedule-poc, since cicero-core loads model/ and logic/
  recursively. The licence keeps copies of their models, which its logic
  uses, and names its template model in package.json
  (accordproject.templateModel).
- Logic imports defineLogic from @accordproject/template-engine/logic and
  its factories from logic/generated/types.ts, which template-engine-codegen
  writes with Concerto's interfaces (npm run compile). runtime/ and
  scripts/generate-types.js are removed.
- Tests use @accordproject/template-engine/testing, and the agreement tests
  run on template-engine's AgreementProcessor, which compiles and loads each
  template's logic. Without a direct concerto-core import, the vitest alias
  around concerto-core's ESM version is no longer needed.
- The library depends on template-engine and cicero-core from the dist
  branches of accordproject/template-engine#187 and
  accordproject/template-archive#950, so the render suite loads, drafts,
  initialises and triggers all three templates; the expectedLoadFailures
  entry is removed.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants