Repository navigation
Conversation
Prototypes migrating copyright-license's nested PaymentClause onto the model design proposed in accordproject/models#200 ("Agreement 1.0 Model Redesign"): composition over inheritance (TemplateData/ClauseData composed into an AgreementDocument instead of subclassing Contract/Clause), a unified Party type replacing the duplicated licensee*/licensor* string fields, and clause instances addressed by path through a Concerto 4 Map. The vendored party@0.1.0/agreement@0.1.0 models, sample.json round-trip, and trigger() logic all work end to end. Natural-language rendering is marked as an expected failure: markdown-template's grammar resolution only looks at properties declared directly on the @template class and never walks the supertype chain, so a composed/inherited envelope isn't renderable with today's tooling -- consistent with that PR being flagged "a design target, not migration-ready". Details are in the model file comments and the template's README. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS Signed-off-by: Claude <noreply@anthropic.com>
npm ci failed in CI because the new workspace package wasn't reflected in the lock file. Added only the two entries npm install generates for the new workspace, leaving pre-existing unrelated version drift in the lock file untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS Signed-off-by: Claude <noreply@anthropic.com>
df08e5d to
439fa91
Compare
The model design proposed in accordproject/models#200 has moved on substantially since this prototype was written. Bring it back in line: - No `@template` decorator, no envelope class. A template's model now declares exactly one concrete subtype of `templatedata@1.0.0.TemplateData`, and that subtype IS the template model (`CopyrightLicenseData`), carrying its variables directly. This also fixes the specific rendering gap the previous revision hit: TemplateMark's TypeVisitor resolves properties via `ClassDeclaration#getOwnProperty`, which doesn't walk supertypes, so an empty `TemplateModel extends AgreementDocument {}` could never resolve its inherited `data`. Rooting the grammar at the data itself removes the `{{#with data}}` wrapper and the problem it hit. - No `clauses` map. `copyright-license` has no sub-template archive -- `{{#clause paymentTerms}}` is an inline grammar block in this template's own grammar -- so `PaymentTerms` is simply a nested ordinary concept, addressed as a subtree of the data. This removes the data-duplication `logic.ts` previously had to paper over with `clauses['paymentTerms']?.data ?? licenseData.paymentTerms`. - `licensee`/`licensor` are `PartyRef` values (a portable embedded reference), not `--> Party` relationships. A relationship reaches `trigger()` as an unresolvable `"resource:...#me"` string with no registry to resolve it against; `resolveParty()` is gone along with the relationship. `--> Party` belongs on the envelope's `AgreementParty`, where a registry exists (see model/agreement.cto, which documents that wider envelope even though this template's own model has none to be composed onto). - Renamed the vendored `data@1.0.0` stand-in to `templatedata@1.0.0`, split into its own model/templatedata.cto per the current namespace split, and updated model/party.cto (adds `PartyRef`) and model/agreement.cto (drops `Clause.path`, adds `AgreementParty`, documents why `Clause`/`Clauses` are out of scope for this prototype) to match. Empirically, removing `@template` fixes rendering but trades it for a worse problem: the installed `@accordproject/cicero-core` (2.1.1, and the copy vendored inside `@accordproject/template-engine`) finds a template's root exclusively via the `@template` decorator, and `Template#validate()` -- called unconditionally by `Template.fromDirectory()` -- calls `getTemplateModel()` unconditionally too. So without the decorator this template cannot be *loaded* at all with today's toolchain, let alone drafted or triggered -- confirmed empirically (see README). The fix is accordproject/template-archive#946, which is not released. `@template` has deliberately not been added back -- that would paper over the exact gap this prototype exists to demonstrate. Instead, test/render.test.mjs gains an `expectedLoadFailures` set (a strict superset of `expectedFailures`, since a template here can't even load) covering this template in both the render and trigger describes, each `it.fails` naming template-archive#946, and the module-level template-loading probe now tolerates a known load failure without taking down the whole render-test file for every other template. npm run test --workspaces --if-present: 49/49 workspace test files pass (212 tests). npm run test:render: 114 passed, 5 expected fail (of 119), 0 unexpected failures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NPtNYorvvn7MQwTovLXp2r Signed-off-by: Claude <noreply@anthropic.com>
Align the Accord dependency graph with Concerto v5 and update templates for strict v5 validation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Matt Roberts <code@rbrts.uk>
Include the optional zod peer selected by current npm 11 so CI clean installs remain reproducible. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Matt Roberts <code@rbrts.uk>
Add explicit AgreementDocument provenance fixtures and a Vitest evidence harness that distinguishes composed sub-template provenance (clauses map present) from inline-only clause usage (clauses map absent), and document repro steps in the prototype README. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Matt Roberts <code@rbrts.uk>
|
Added composed-template provenance evidence for models#200 closure in this PR. What was added
Repro commandnpx vitest run test/composed-template-provenance.evidence.test.mjsObserved/asserted results
Note: this environment does not have |
|
Reviewer note: the earlier fixture JSON in this PR captures intended A follow-up update is now being prepared to provide execution-backed evidence for two separate archives (with explicit reproduction details), plus clear documentation of current API/tooling limits and template-archive#946 gating. |
Replaces fixture-only envelope assertions with execution-backed provenance binding. The evidence test now loads parent and child templates independently, round-trips each through CTA archives, instantiates a child Clause from the child archive, and binds the child template reference/hash at the parent clause path. This proves archive-level provenance boundaries with concrete runtime-derived identifiers and hashes. README now explicitly states what is and is not proven: this demonstrates executable provenance binding semantics, while native contract+child archive composition remains unavailable as a first-class cicero-core API, and models#200 parent loading remains gated on template-archive#946. Local validation execution remains blocked in this environment because node/npm binaries are unavailable. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Matt Roberts <code@rbrts.uk>
|
Superseding update for reviewers: commit What changed:
Repro: npx vitest run test/composed-template-provenance.evidence.test.mjsNote: local command execution remains blocked in this CLI environment if |
composition-binding.json's parentTemplate/clauses.paymentClause.template
paths were off by one directory level ("../copyright-license" /
"../payment-upon-signature"), so Template.fromDirectory() couldn't find
either template's package.json from evidence/. Both templates actually
live two levels up from evidence/ (evidence -> copyright-license-agreement-poc
-> src -> <template>), confirmed by running the new evidence test locally
and by CI's "Unit Tests (22.x, ubuntu-latest)" failing with the same error.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
Signed-off-by: Claude <noreply@anthropic.com>
d065a7c to
46e45a3
Compare
The fixtures project provenance from independently loaded templates but do not exercise URI resolution or parent-child composition. Remove them rather than imply Cicero currently supports that behavior; model extensibility can be assessed independently. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Matt Roberts <code@rbrts.uk>
|
Correction to the earlier composition-evidence comments: the fixture-only and two-independently-loaded-archive harnesses have been removed in commit What #528 now claims is limited to models#200 extensibility: Actual reference resolution/composition remains a major Cicero/TemplateMark/template-engine feature and is explicitly out of scope for this prototype. |
…e state Show how state works under models#200: the template declares one StateData subtype (CopyrightLicenseState) holding agreement-scoped status, with the inline payment clause's state as a nested subtree at the same instance path as its data. init() seeds it, PaymentRequest and a new PaymentReceived request transition it, and paying in full moves the clause to PAID and the licence to IN_FORCE in one returned state. A vendored runtime@1.0.0 stand-in models the AgreementState envelope the runtime owns around that state. The README documents that today's toolchain only recognises state as a subclass of org.accordproject.runtime@0.2.0.State, so this state would not be detected even once template-archive#946 lands. 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>
…ycle Rework the state illustration around design decisions for models#200: - The payment lifecycle is an obligation@1.0.0 PaymentObligation, not a status enum in template state. Clause state keeps only facts (amountPaid, dueAt); logic derives the obligation's status and revision from them and emits ObligationTransition events. The licence being in force is derived (obligation FULFILLED), not stored. - init() issues the obligation via a proposed ObligationIssued event; obligation id and AgreementReference use the clause path, with the runtime expected to back-fill agreementId. - Amounts are PreciseAmount (digit-string unscaledValue, BigInt maths), rendered with a grammar formula; overpayment is rejected. - The runtime stand-in sketches per-document state (documentStates). - Logic is deterministic: timestamps come from data or requests. 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>
…ts PreciseAmount template-engine 5.1.0 already drafts org.accordproject.money@1.PreciseAmount natively; the grammar formula is only needed because this repo pins 4.0.0 and the vendored money stand-in doesn't match the drafter's namespace key. 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>
…1 DX Add @accordproject/template-engine 5.1.0 as a devDependency of this workspace only (the rest of the repo stays on 4.0.0), with tests showing: - the template renders end to end when the root concept is named explicitly, with no @template decorator; - money@1.0.0 PreciseAmount is drafted natively, so the grammar uses a plain {{amount}} instead of a formula; - logic.ts type-checks against 5.1's injected runtime declarations. Vendor models#200's money@1.0.0 verbatim under its real namespace: its BigInteger is a String scalar it declares itself, so it compiles with the repo's Concerto 4 toolchain (correcting an earlier claim that it could not). Type response events with the model's event types and take timestamp types from generated interfaces, since 5.1's codegen maps DateTime to string where Concerto 4's maps it to Date. 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>
…emplate instances
Prototype a proposed alternative to models#200's agreement/runtime shapes
that supports embedded executable clauses with a single structure for the
template hierarchy:
- agreement: an AgreementDocument has a root TemplateInstance
{ instanceId, template, data, children }. Inline clauses stay subtrees
of a template's data; composed clauses are child instances with their
own template and data.
- runtime: AgreementState.states indexes each stateful instance's own
StateData by stable instanceId, so state never mirrors the tree.
- logic: a document's logic gets handles to its composed clauses, sends
them requests, and returns its own state plus theirs; the runtime
commits them as one revision or nothing.
Example: an agreement of two documents, the licence (inline payment
terms plus a composed late payment clause with its own model, grammar
and logic) and a stateless licensed-work schedule, driven end to end by
a runtime stand-in (agreement/host.ts) and validated against the models.
Compile this workspace with concerto-cli 4.2.0 (Concerto 5): the repo's
4.0.1 codegen drops the import for a type used only as a map value.
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>
…logic API on models#200 1.0.0 Move the prototype onto models#200's real 1.0.0 namespaces, vendored verbatim, with design B's changes in one proposal namespace (poc.accordproject.composition@0.1.0) as subtypes of the types they would change: ComposedClause, IndexedAgreementState, DocumentReference and ObligationIssued. Drop the runtime@0.2.0 and contract@0.2.0 copies and the poc stand-ins. Prototype the proposed logic API in runtime/: - defineLogic().init().on(RequestType, (request, self) => ...): one handler per request type, dispatched on $class (or the nearest supertype), with no switch; the handlers' signatures are the API a composing template triggers (ApiOf / Clause). - self is the instance's node in the agreement tree, with read-only views of its parent, clauses, document and cousins. - Handlers write only through self (setState, emit, triggering their own composed clauses), buffered in a transaction that commits as one revision; each clause runs in a nested transaction discarded if it throws. - execute()/initialise() are JSON-to-JSON, so the agreement can run as a stateless function with conditional writes. - testInstance/stubClause run unit tests on the same transaction code. Port both logic files, and add tests for the engine's semantics, a retried conditional write, and compile-time checks of the typing, run with tsc. concerto-core 5.0.0's ESM build reports its version as 5.0.0-beta.2 and rejects models#200's `concerto version "^5.0.0"`, so this workspace's tests load its CommonJS build. 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>
…ted type factory Generate a factory per concrete model type (scripts/generate-types.js, run by `npm run compile` after Concerto's codegen, into logic/generated/types.ts): `create()` fills in `$class`, and `$identifier` for identified types; `is()` narrows a value to the type; `ref()` makes a relationship. They replace the hand-written request type constants, and are the keys handlers register under. Both logic files, the prototype runtime and every test now make values with factories, so none writes a `$class` or relationship string by hand. Compile-time checks cover that a factory rejects a hand-written `$class` and requires every field, and a test checks the generated factories against the models. 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>
Session tooling only, for generating illustrations: not part of the template prototype. Reads GEMINI_API_KEY from the environment. Drop this commit before the PR is marked ready. 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>
…nt@1.0.0 prototype The prototype needs template-engine 5 and cicero-core 2.2+, which #529 moves the library to. package-lock.json is taken from #529: this branch's only lockfile change was a workspace-local template-engine 5.1, which the prototype no longer needs. 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
… 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 PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed. |
Summary
This migrates
copyright-licenseonto the org.accordproject 1.0.0 namespaces:The logic is written with template-engine's new logic API (
defineLogic, handlers taking(request, self), run in transactions).The sample now loads, drafts, initialises and triggers end to end through cicero-core and template-engine. It no longer has a local runtime or any test workarounds. The changes it needs upstream are in draft PRs, installed here from their prebuilt dist branches:
Clausegets its owndataandclauses.AgreementReference.documentId.AgreementState.states(one index by instance id).ObligationIssued.TemplateDataparent type, or byaccordproject.templateModelin package.json. Finds state byStateData. Legacy runtime@0.2.0 templates keep working.AgreementProcessor. Drafting uses the named template model.Changes
feat: migrate template library to Concerto v5 #529 merged in. The prototype needs template-engine 5 and cicero-core 2.2+, which feat: migrate template library to Concerto v5 #529 moves the library to. Its changes show in this diff until feat: migrate template library to Concerto v5 #529 merges.
Root dependencies.
@accordproject/template-engineand@accordproject/cicero-corenow come from the dist branches of template-engine#187 and template-archive#950. An override makes the engine share the same cicero-core.Three sibling templates replace the nested
composed/anddocuments/folders, because cicero-core loadsmodel/andlogic/recursively:copyright-license-agreement-poc: the licence. A stateful document with an inline payment clause.late-payment-poc: a stateful clause template, composed into the licence.licensed-work-schedule-poc: a stateless document.The licence keeps copies of the other two templates' models, because its logic uses their types. It names its template model in package.json.
Models.
composition.cto) is removed, because models#205 folds it intoagreement,runtimeandobligation.Logic.
defineLogicand related types from@accordproject/template-engine/logic.logic/generated/types.ts, whichnpm run compile(template-engine-codegen --offline) generates alongside Concerto's interfaces.runtime/andscripts/generate-types.jsare gone.Tests.
@accordproject/template-engine/testing.AgreementProcessor, which compiles and loads each template's logic as it would from its archive. They cover:tsctype-checks both logic files and the compile-time checks against the engine's declarations.Render suite. The
expectedLoadFailuresentry is gone. All three templates compile, draft, init and trigger throughTemplateArchiveProcessor.Flags
.mcp.jsonbefore ready. Commit 0ac00b1 adds a session tooling file (.mcp.json) that should be dropped before this is marked ready.5.0.0-beta.2, so it rejects the 1.0.0 namespaces'concerto version "^5.0.0"(concerto-core 5.0.0 ESM build reports its version as 5.0.0-beta.2, rejectingconcerto version "^5.0.0"models concerto#1462, fix in #1463). These tests now reach concerto-core only through the CommonJS builds of cicero-core and template-engine, so they don't hit it.ClauseDefinitioncan't name a template;TemplateReferenceto an archive. The tests name templates by package name, and hash each template's files as a stand-in forarchiveHash.AgreementProcessorrefuses an agreement whose templates define a shared namespace differently.Validation
npm test(every workspace's unit tests, then the render suite): every workspace passes, including 40 tests in the licence and 3 in late-payment. Render: 123 passed, plus 3 failures that were already expected (the 10 new tests are this PR's three templates).Related Issues
concerto version "^5.0.0"models concerto#1462Author Checklist
--signoffoption of git commit.🤖 Generated with Claude Code
https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
models#200 extensibility conclusion
The attempted composed-template evidence was removed because current Cicero does not yet resolve or compose a referenced child template archive. Loading two archives independently and projecting their identities into an
AgreementDocumentwould only simulate the target shape, not prove composition.The model-level conclusion remains useful and does not require that tooling feature to exist first:
AgreementDocument.clausesrecords provenance at clause instance paths without prescribing how a referenced template is resolved.Clause.templateuses the resolver-neutralTemplateReference(templateId,version, immutablearchiveHash).templateIdunder a profile and verify the returned bytes againstarchiveHashwithout changingAgreementDocumentorClause.TemplateReference; the core agreement model remains typed to the base concept and does not need to be rewritten.clausesentry because no separate template archive was resolved.Cicero/TemplateMark URI resolution and parent-child composition are therefore separate future tooling work, potentially spanning cicero-core, markdown/TemplateMark handling, and template-engine. This PR does not claim to implement or validate that feature.