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
Validation logic #5
Comments
@jvanbockryck did you learn anything from Wim that would be useful for validations? I know he was working on documenting and implementing REA model constraints. |
Yes @bhaugen, Wim is going to send me documentation on this topic. The approach can be as on any other data modelling language that you extend with a formal constraint language. I've done such things on UML before (see INSPIRE data specs, they are full of them), but that's not so useful to generated anything from, although some have tried with some success (see shapechange.net, transformations section). Wim's proposition is doing this on the ontology layer, so that constraints could be generated for multiple constraint languages at a lower level (e.g. to RUST/Holochain validations). I've had good results with this approach in the past on the topic of Complex Event Processing, that deals not only with constraints on the schema - object/events instance - but also on a series of events, dependencies between events. So I "clicked" with him on that approach. I like to work out an example for this approach for Value Flows, as it could then be used to generate constraints for any other lower level implementation (if there's a demand for that), but Holochain/HoloREA would be my first to try this out. I say Holochain/HoloREA, because I think it is useful for all Holochain apps, not only HoloREA. With that example and with the input from Wim, I would like to show this to @pospi to see if it would make sense to him. |
Observation layer validations Note: This is a draft, comments appreciated. Meant to be implementation agnostic. Process
EconomicEvent
EconomicResource
Fulfillment
Appreciation
|
Planning layer validations Intent
Commitment
Satisfaction
Agreement
Claim
Settlement
Plan
Scenario
|
Specification validations ResourceSpecification
ProcessSpecification
|
@jvanbockryck you're talking about a lot of things there that I have no familiarity with, but I'm game. When have materials ready for discussion just hit me up :) Is what you're proposing basically a way of generating the constraints that Lynn has outlined above? Or is it a different type of constraints that you're talking about? |
Well, the ones listed by @fosterlynn of mostly of one type of constraint, "is required" and the occasional "or" between attributes.
Then there are other more complex types that I'm going to demonstrate with my example, later on. |
If I understand what you mean correctly, this might be different for different technologies, for example in Holochain it is the hash token, for linked open data it is a uri. So it might be defined more generally for the VF app specs and more specifically for a technology-related validation. |
Yes, @fosterlynn , that's correct on the format. But also, the referenced objects must exist. |
@jvanbockryck on the topic of these:
In Holochain these require some thought towards cyclic inter-network dependencies, see this forum thread (CC @pdaoust) But all these constraint types you are talking about would be really good things to formalise :) |
@fosterlynn it occurs to me that all the validations given so far are in the context of creating new records. Would you be able to provide a similar list of constraints for update operations? |
RE |
Also in terms of the "adjoining" records, I think I prefer to have the quantity explicitly stated in the Fulfillment / Satisfaction / Settlement. Otherwise it's just another condition that has to be programmed in to every app... |
Oops, never sent this....
I can help with that if needed. That is also defined in the graphql spec, but not so easy to look at it there.
When I said "required" that should also mean that for relationships the object exists. Will that work? But anyhow @jvanbockryck good ideas!
Yes, can do.
I think that either EcononomicEvent.resourceConformsTo or EconomicEvent.resourceClassifiedAs if available on the event should be also put on the EconomicResource. At least on create. Does this answer the question? I think I'm missing the thought process behind the one you posed?
OK. The UI can handle it then if there is no functional need to have both for some use cases, which will frequently be true. We did decide to do them as separate mutations, right? |
Actually, I think they are a subset of the ones defined for create. Nothing is required besides the ID. Then people can't remove anything that was required on create, like set to null or take to zero, etc. |
Half way there! Confirming: currently
|
Also @fosterlynn curious whether There are also no requirements on a pairing of |
RE updates, this is the current situation. Please correct as needed:
|
Depends on what you mean by "mess with quantities". A move will often result in a different resource identifier, even though visually it is the same set of material items. This is because some operations include location in the logical identifer, so there will be a different technical identifier on the from and the to resources. So, in those cases, the from is decremented and the to is incremented. Note also the to resource may already exist, or not. A move could also just update the currentLocation property, and keep everything else, if there is not a toResourceInventoriedAs on the move. That is for cases where the location is not part of the logical identifier. I see cc @bhaugen |
I don't think so. Agents can always have resources that are not inventoried in their computer system explicitly, is an administrative choice. cc @bhaugen |
Right, deletable is never editable on any record, the app figures that out.
I honestly don't see anything on Commitment or Intent that is above the "# inverse relationships and queries" line that can't be edited. People make data entry mistakes. This assumes that the app is keeping track of these changes functional-style - which I understand both holochain and activity pub do out of the box. Any disagreements and is my understanding correct?
Thinking about it now, seems like we should add a validation that satisfaction and fulfillment should not have quantities greater than that which they satisfy or fulfill. Same with settlement. Yeah, I think reversing entries would be appropriate for Fulfillments and Settlements, I can see where they might affect accounting entries like receivables or payables. Intents don't need so much ceremony around them, as they aren't part of any periodic accounting I can think of. So it seems to me that Satisfaction could allow anything to be editable? Please double check me @bhaugen ? |
I didn't think that was the case... what about over-satisfying? RE the move event stuff, this manifested for me as unexpected behaviour when this test assertion failed and I eventually traced the problem back to this event decrementing the resource quantity. I wasn't expecting that, and the logic must not have been clear because I interpreted that as a passing test earlier. It seems to me that if you are going to Also no confirmation yet on- currently |
Re The reason I suggest this is that in a distributed environment, I'm not sure what importance remote actors might place on the presence of A similar issue exists with third-party modules interpreting So I think if you need to alter fields in either of the above, maybe it's an "append new record to correct" thing? But then I wonder about @tommycp3 @bhaugen @fosterlynn care to comment on the above from the perspective of real industry use-cases? |
I'm re-thinking, and I think you are right, people can put what it is, and over-satisfying is fine. In general, I want to be more careful about over-specifying validations.
What about the case where it is changing location but not identification - they should enter the resource id in both places? Because they'll need the resourceInventoriedAs to properly identify the resource to be moved. In that case, we could leave the resource identified as is, meaning no decrement or increment. What do you think? Could also work to require both or neither.
Sorry I have probably confused this, I keep forgetting the change we made to the definitions of conformsTo and classifiedAs here valueflows/valueflows#520. But, talked to @bhaugen , and we are thinking that we should not be too prescriptive, and let people have all resource references as optional. For example in a timebank near us, they have basically a description, and some very non-specific classifications, at most, for the service being given in return for mutual credit. So that means, not required on the event. keep if it's not present then use it from the event. But no errors. Should we override the resource.conformsTo if another event comes along with a different event.resourceConformsTo?
Yes, it may not have all the unchangeables that events have because there is no need to use it to recreate resources. Talking with @bhaugen , his suggestion is that commitments could be changeable (if agreed by both agents) until there is an event. Once an event happens, the commitments have to be backed out and re-put-in, because if an event happens, then there is an (implied) claim, which would translate to a receivable or payable on an agent's books, so now we are into accounting periods that might be closed. The ones I see that would affect the books are: the quantities and inScopeOf (that's whose books it will show up on). |
I'll take that as a nod to lock in this validation for RE
I think the answer here is "no", for the same reason that we shouldn't be able to edit
I read that as you saying that
For clarification: Do we need more complex validation regarding "until there is an event"? This sounds like a separate, more complex task. Does this involve following links through a I am not sure I agree that Also, there is a problem if |
A general thought: I'm having trouble thinking about the implications of distributed data for a lot of this. And there are a lot of very different use cases for HoloREA, many of which we have not encountered. I think we have to get some more experience. I don't know whether that means we go in with minimal validations and add them as we learn; or go in with more validations and subtract them as we learn. The other factor that I don't yet understand in practice is what the responsibilities of HoloREA are as a "framework". That may imply looser validations, if the architecture will allow apps using the framework to add their own, which I don't know? But in general, I don't want to go too crazy trying to define something we can't fully understand yet.
Yes, @bhaugen and I were re-thinking the earlier decision, sorry about the change. Thinking about some of the simpler implementations people might want to do. Is there any reason the app requires it to be present for its internal logic?
I don't see any problem with adding as editable resourceClassifiedAs, due, atLocation, off the top of my head. Might be more, but we can leave them as is. @bhaugen ?
An addition to what we said earlier: This only applies to commitments that are part of an Agreement (has a clauseOf). Commitments that are only related to processes shouldn't affect any accounting reports as far as we can think. In terms of how to tell, you could query for EconomicEvents with realizationOf equal to the clauseOf the commitment. Unless we aren't saving realizationOf when we create a Fulfillment, then you would have to check all the commitments of that agreement for fulfillments. (Either is fine, we just need to be consistent.)
inScopeOf will often be the scope the accounting is being done for. Like the name at the top of a balance sheet or income statement could be the name of the inScopeOf object. On the other hand, not everything goes into that kind of periodic report that is officially 'closed'. Just EconomicEvents and Commitments that are part of an Agreement is I think our working definition. So it would be not editable for those. On the other hand, if change of scope means a record could be in the wrong dht or something like that, then we shouldn't allow editing it, people will have to delete it and re-enter. Will that ever happen? |
The only reason so far is for inferring This basically means allowing
Probably. It's really hard to say without having come to any final conclusions on what group agents mean in Holochain. I think there might be cases where On Commitment & Intent, I'm finding getting clarity from you on what is updateable really difficult. I'm going to go ahead with updating
I feel iffy about making the time fields editable, but given there is revision history this might be OK. That said, you might want to create some constraint in the app specs that revisions must be kept for Commitments & Intents if you are going to allow these sorts of edits. I guess my main question is- if a I still don't have any guidance on an editable field list for |
I understand, and am not immediately sure how to improve the state of knowledge on some of it. Certainly we can consolidate the messy history of discussion, and also derive from the code. In the meantime, I think best to just go for your suggestions (which you probably did already), and we'll shake it out with some users. I'll document the Commitments with Events thing in your separate issue.
For Commitments, I think the coordination is contained within the IPO structure, distributed or not. I don't see this as "broadcast". So it is just a change or a delete, same for everyone coordinating a process. Depending on the use case, notifications are very useful for this kind of coordination.
To "de-list" an Intent, change the Proposal.hasEnd date to now. In this case the model is explicit about the listing of intents.
good idea, will do |
Ok. Does that mean that marketplace-type networks always need to plug in to |
Rather than go with my prior suggestions I'm going to err on the side of being permissive for now. So that means all the accounting fields of Ping me of any further updates to this logic so that I can address in Holo-REA as requirements solidify, but I'll go ahead and submit a PR for now. |
Yes, that is what it is for - for when intents need to be published out to find matches.
OK, let's give it a try. |
Are there any validation rules for |
I don't see anything that is absolutely required. Something has to be there, but won't always be the same thing, but I also don't see getting into some either or or or thing. Let's let specific apps figure it out. |
We have moved the ValueFlows organization from GitHub to https://lab.allmende.io/valueflows. This issue has been closed here, and all further discussion on this issue can be done at If you have not done so, you are very welcome to register at https://lab.allmende.io and join the ValueFlows organization there. |
Beyond schema validation we need to define all the custom validation rules that apply to records at the API boundary. This includes validation for 'either' fields as well as any other custom dependencies, existence checks and domain-specific constraints that need to be imposed in order for requests to be considered valid.
Starting with the observation, planning & specification records (in that order) would be optimal in terms of informing HoloREA's development as it progresses.
The text was updated successfully, but these errors were encountered: