Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify / make more uniform handling for templates without logic #597

Open
jeromesimeon opened this issue Oct 7, 2020 · 14 comments · May be fixed by accordproject/ergo#817
Open

Clarify / make more uniform handling for templates without logic #597

jeromesimeon opened this issue Oct 7, 2020 · 14 comments · May be fixed by accordproject/ergo#817

Comments

@jeromesimeon
Copy link
Member

jeromesimeon commented Oct 7, 2020

Is your feature request related to a problem? Please describe.
Currently:

  • templates without logic or formulas support parse and draft but no other command (e.g., initialize or trigger)
  • templates with logic support all commands
  • templates without logic but with formulas are handled like contracts with logic

This can be a bit surprising, especially cicero initialize sometimes works when there is no logic (e.g., when a formula is in the template grammar).

Also this means testing logicless templates is somewhat cumbersome / different from other templates.

This can also mean some API calls will throw lower-level exceptions for logicless templates in some cases.

Describe the solution you'd like
More uniform handling of templates with or without logic. For instance:

  • Contracts without logic are treated as having empty contract logic (i.e., a contract with a single default initialize clause)

Additional context
Example with the signature block template from https://templates.accordproject.org/[email protected]

bash-3.2$ cicero --version
0.21.9
bash-3.2$ cicero parse 
2:49:18 PM - info: Using current directory as template folder
2:49:18 PM - info: Loading a default text/sample.md file.
2:49:19 PM - info:
{
  "$class": "org.accordproject.signature.tnd.TitleNameDateSignatureBlock",
  "title": "Title",
  "signature": "--------",
  "fullName": "Full Name",
  "dateSigned": "Date Signed",
  "signatory": "resource:org.accordproject.cicero.contract.AccordParty#[email protected]",
  "clauseId": "ddb2dcef-97ba-4aa4-ab70-7cc1002d0a52"
}
bash-3.2$ cicero initialize 
2:49:22 PM - info: Using current directory as template folder
2:49:22 PM - info: Loading a default text/sample.md file.
2:49:23 PM - error: Did not find any compiled JavaScript logic
@jeromesimeon
Copy link
Member Author

^^^ @dselman

@jeromesimeon
Copy link
Member Author

Note, this also mean that logicless templates, currently, cannot be open in template studio:

Screenshot 2020-10-07 at 3 07 41 PM

Screenshot 2020-10-07 at 3 07 18 PM

@sanketshevkar
Copy link
Member

@jeromesimeon while investigating this issue, I was working with ergo-engine code. I found out the following behaviour.

  • While I was using ergo-engine v0.21.9 I was able to use init method and it gave a output as expected. I initialised the helloworldstate template.
  • But then I linked the ergo-engine v0.22.0 alpha.4 that time using init method gave out this error.
(node:29066) UnhandledPromiseRejectionWarning: TypeNotFoundException: Namespace is not defined for type org.accordproject.runtime.State
    at APModelManager.getType (/home/user/Desktop/templateHandling/node_modules/@accordproject/concerto-core/lib/modelmanager.js:569:19)
    at Serializer.fromJSON (/home/user/Desktop/templateHandling/node_modules/@accordproject/concerto-core/lib/serializer.js:149:52)
    at LogicManager.validateInput (/home/user/Desktop/templateHandling/node_modules/@accordproject/ergo-compiler/lib/logicmanager.js:324:39)
    at VMEngine.invoke (/home/user/Documents/ergo/packages/ergo-engine/lib/engine.js:170:34)
    at VMEngine.init (/home/user/Documents/ergo/packages/ergo-engine/lib/engine.js:215:21)
    at Engine.init (/home/user/Desktop/templateHandling/node_modules/@accordproject/cicero-engine/lib/engine.js:85:32)
    at main (/home/user/Desktop/templateHandling/index.js:20:30)

.

I guess v0.22.0 still must be in development so just thought of reporting this behaviour to you.

@sanketshevkar
Copy link
Member

Hello @jeromesimeon ,
I wanted to test a template with formulae but without logic. Can you please suggest a template that I can use for the same?

@jeromesimeon
Copy link
Member Author

I guess v0.22.0 still must be in development so just thought of reporting this behaviour to you.

It's expected. Not really because Ergo 0.22 is still an alpha version (although, of course it is), but simply because that new version is a breaking change so we have to make changes to template studio to support it.

@jeromesimeon
Copy link
Member Author

Hello @jeromesimeon ,
I wanted to test a template with formulae but without logic. Can you please suggest a template that I can use for the same?

Look in the template library for templates without a logic directory (I think there are a few).

@jeromesimeon
Copy link
Member Author

Hello @jeromesimeon ,
I wanted to test a template with formulae but without logic. Can you please suggest a template that I can use for the same?

Look in the template library for templates without a logic directory (I think there are a few).

@sanketshevkar I think I read your question a little fast. I don't think there is one without logic but with formulae... Someone will have to try and create one!

@sanketshevkar
Copy link
Member

@jeromesimeon I have searched templates in cicero template library, but found none.

Also, I was curious that what would be the cases where there could be a need to initialize and trigger templates without logic? Since no logic involved, there is no state type, request type, response type and emit type associated with it.

If we want to initialize these templates we'll need at least need a state type and a response type associated with it. Is that correct?

@jeromesimeon
Copy link
Member Author

@jeromesimeon I have searched templates in cicero template library, but found none.

Also, I was curious that what would be the cases where there could be a need to initialize and trigger templates without logic? Since no logic involved, there is no state type, request type, response type and emit type associated with it.

If we want to initialize these templates we'll need at least need a state type and a response type associated with it. Is that correct?

Those are all good question. I think it depends how you think of "no logic" is it really no logic, or is it "empty logic" in which case you could have a default initialisation to an empty state and no request would trigger execution but the trigger call could still exist.

@sanketshevkar
Copy link
Member

sanketshevkar commented Apr 15, 2021

Thank you @jeromesimeon. I think this problem is better handled from the ergo packages than cicero. I am trying the same. Would that be the correct thing to do?

Also, do all templates need to have a contractName? I am the same signature block template you used above. I'm getting a error in ergo-engine because the contractName is null.

(node:11895) UnhandledPromiseRejectionWarning: Error: Cannot create invoke call for target: cicero without a contract name
    at LogicManager.getInvokeCall (/home/user/Documents/ergo/packages/ergo-compiler/lib/logicmanager.js:144:23)
    at VMEngine.invoke (/home/user/Documents/ergo/packages/ergo-engine/lib/engine.js:180:34)
    at VMEngine.init (/home/user/Documents/ergo/packages/ergo-engine/lib/engine.js:227:21)
    at Engine.init (/home/user/Desktop/templateHandling/node_modules/@accordproject/cicero-engine/lib/engine.js:85:32)

@jeromesimeon
Copy link
Member Author

@sanketshevkar I think it could probably be handled directly in template studio? This would be worth investigating as it's much less intrusive. (i.e., not do the invoke call in the first place)

@sanketshevkar
Copy link
Member

@jeromesimeon, yeah I'll investigate this approach too. But then cicero init & cicero trigger would still fail.

I have changed some code on the ergo-engine and ergo-compiler v0.21.9 to solve this issue. Should I create a PR for that?

@jeromesimeon
Copy link
Member Author

jeromesimeon commented Apr 15, 2021

@jeromesimeon, yeah I'll investigate this approach too. But then cicero init & cicero trigger would still fail.

I have changed some code on the ergo-engine and ergo-compiler v0.21.9 to solve this issue. Should I create a PR for that?

Right. yes sorry I confused two different issues here maybe. If we do want to support initialise even in the absence of user-logic, it's quite possible that doing it in Ergo as you suggest would be better. And sure, if you have something to review, I'll be happy to take a look!

@sanketshevkar
Copy link
Member

@jeromesimeon, yeah I'll investigate this approach too. But then cicero init & cicero trigger would still fail.
I have changed some code on the ergo-engine and ergo-compiler v0.21.9 to solve this issue. Should I create a PR for that?

Right. yes sorry I confused two different issues here maybe. If we do want to support initialise even in the absence of user-logic, it's quite possible that doing it in Ergo as you suggest would be better. And sure, if you have something to review, I'll be happy to take a look!

Hi @jeromesimeon,

I have created a PR for the ergo respository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants