Repository navigation
Conversation
The request, response, emit and state type lookups now report the concrete subtypes of both the 1.0 base types and the legacy org.accordproject.runtime@0.2.0 ones (Request, Response, Obligation, State), de-duplicated, 1.0 types first. Base types whose namespace is not loaded still contribute nothing. isStateful() is true when the model declares a concrete subtype of templatedata@1.0.0.StateData or of runtime@0.2.0.State. The legacy State is a concrete empty asset, so it is excluded explicitly, as before 1.0. Most templates in cicero-template-library target cicero ^2.0.0 but still model their runtime types with runtime@0.2.0, and must keep working alongside templates on the 1.0 models. 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
A template that composes other templates carries copies of their models, each with its own concrete subtype of TemplateData, so finding the template model as the one TemplateData subtype is ambiguous. package.json may now name it with accordproject.templateModel, exposed as Metadata#getTemplateModelName(). getTemplateModel() returns the named type when set, and throws if it is missing or is not a concrete subtype of TemplateData (or, for legacy templates, a concrete type with @template). Otherwise it resolves as before: the one concrete TemplateData subtype, an error if there are several (which now suggests accordproject.templateModel), or the @template decorator if there are none. 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
getRequestTypes, getResponseTypes, getEmitTypes and getStateTypes were emitted in lib/template.d.ts as returning unknown[], because the new findConcreteSubclassNamesOfAny helper de-duplicates through a Set of an untyped array. That broke consumers typed against string[], such as template-engine's LLMExecutor (TS2322). Annotate the helper and the four getters as string[]. 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
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
4 tasks done
Merged
5 tasks done
Contributor
|
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #946
This builds on #946 (
feat(cicero-core)!: require the 1.0 runtime models) and targets its branch.#946 moves
getRequestTypes/getResponseTypes/getEmitTypes/getStateTypes/isStatefulfromorg.accordproject.runtime@0.2.0to the 1.0 models. On its own, that change breaks every template that still models its runtime types withruntime@0.2.0. In accordproject/cicero-template-library that is about 57 templates. They target cicero^2.0.0, so they pass the version check, but they would then report no request, response, state or emit types. These templates have to keep working with the next cicero-core, next to new templates on the 1.0 models.This PR also lets a template that composes other templates say which
TemplateDatasubtype is its own template model.Changes
packages/cicero-core/src/template.ts)LEGACY_REQUEST_TYPE,LEGACY_RESPONSE_TYPE,LEGACY_EMIT_TYPEandLEGACY_STATE_TYPE(org.accordproject.runtime@0.2.0.{Request,Response,Obligation,State}), documented next to feat(cicero-core)!: require the 1.0 runtime models #946's constants.findConcreteSubclassNamesstill treats a namespace that is not loaded as contributing nothing.isStateful()is true when the model declares a concrete subtype oftemplatedata@1.0.0.StateDataor ofruntime@0.2.0.State. The legacyStateis a concrete empty asset, so it is excluded explicitly withexcludeBaseType, as onmain.accordproject.templateModel)TemplateDatasubtype. For example, a licence that creates a composed late-payment clause's requests, or reads a schedule document's data.package.jsonmay now name the template model:"accordproject": { "templateModel": "<fully qualified name>" }.Metadata#getTemplateModelName()returns the name, orundefinedwhen the key is absent. Metadata rejects a value that is not a non-empty string.createTargetMetadatadeep-copiespackage.json, so the key is kept there and through archive round-trips. Both are tested.getTemplateModel()resolves the model in this order:templateModelis set. It throws if the type is not found, or if it is not a concrete subtype ofTemplateDataor (for legacy templates) a concrete type with@template;TemplateDatasubtype;accordproject.templateModel;@templatefallback, unchanged.test/template.test.ts,test/metadata.test.ts)legacy-runtime-cicero2: a cicero^2.0.0template onruntime@0.2.0with a request, a response, aStatesubtype and anObligationsubtype. It is shaped like the cicero-template-library templates, and it reports all of those types andisStateful() === true.helloemit): reports its 1.0 types andisStateful() === true.no-template-decoratorloadsStateDatabut declares no subtype of it, soisStateful() === false.no-runtime-namespacetests still cover the case where neither runtime namespace is loaded (empty lists and false).composed-template-model: a licence model plus a copy of a late-payment model, giving twoTemplateDatasubtypes, withtemplateModelset. The tests check that:accordproject.templateModel;TemplateDataare each rejected;@templatetype is accepted.Flags
legacy-runtimefixture targets cicero^1.0.0, so the version check still rejects it before any runtime lookup runs. That is why this PR addslegacy-runtime-cicero2instead of reusing it. The fixture's description ("rather than silently loading with no runtime types") is now a little out of date. I left it as is.getStateTypes()includes the concrete baseruntime@0.2.0.State, as it did onmain.isStateful()excludes it.npm ci, thennpm test -w @accordproject/cicero-core(lint, license check, build, jest): 193 passed, 5 failed, 2 skipped, and thetemplatelibrarysuite fails to run.cff6a1a) without this change: 169 passed, 5 failed, 2 skipped, with the same failing tests and suite.should create a template from a directory and download external models by default(models.accordproject.org);templatelibrarysuite (templates.accordproject.org). Jest's worker then crashes serialising the circular axios error.should roundtrip a template with a logo,… a source template (CR),… a compiled template (JavaScript)and#getHash. They may come from the merge ofmaininto feat(cicero-core)!: require the 1.0 runtime models #946, but I have not confirmed that.Related Issues
Author Checklist
--signoffoption of git commit.masterfromfork:branchname🤖 Generated with Claude Code
https://claude.ai/code/session_011LWZaJoaq9HFMVceNxCXMS
Generated by Claude Code