dyne / zenpub

Reflow federated economic network
GNU Affero General Public License v3.0
13 stars 3 forks source link

Ownership of resource unclear #58

Open pral2a opened 3 years ago

pral2a commented 3 years ago

After transferring an economicResource to a new agent using an economicEvent a new economicResource is created. However, the former agent still has editing capabilities over the new economicResource.

Could you confirm that the behaviour is correct?

sbocconi commented 3 years ago

I am not clear why a new economicResource is created after a transfer?

This does not sound in line with tracking a resources across a flow, I would think that a new resource is created only when particular events are performed, such as produce if I remember correctly.

pral2a commented 3 years ago

To add clarity. Those are two separate issues:

  1. Ownership or editing capabilities on newly created resources not owned by the agent. That is a backend related issue. https://github.com/dyne/zenpub/issues/58#issue-990233438
  2. Duplication of resources after an event (i.e. transfer). That is a front-end implementation issue we are tackling here https://github.com/reflow-project/weloop/issues/107#issuecomment-914517053
ocataco commented 3 years ago

I am experiencing a similar issue.

When I perform a transfer from provider to receiver, the corresponding economic resource is not updated to have the receiver as the accountable agent.

In a simulation I’ve created a transfer event of a lot that contains a couple of medical gowns (tracking id’s are in the manifest in the note). See here the ouput of a recorded transfer event:

{ "data": { "economicEvent": { "id": "01FDV09AQ8MSPGSTJK9BC0PDY0", "provider": { "id": "01FDSF07W22B3TMYF9HB2RG0QR", "name": "clean lease a_tsc" }, "receiver": { "id": "01FDSEWBCPJ7H8NWHMGK531NAD", "name": "olvg a_hospital" }, "resourceInventoriedAs": { "id": "01FDV09AEM1QTFQ8EYBBPT67NP", "name": "Gown Lot", "note": "Manifest: http://cleanlease.nl/zs/0471b80b-0301-4aa5-92d0-6a1de73239be,http://cleanlease.nl/zs/3845418d-cdf2-4cd1-81b9-90c783d0fdd1,http://cleanlease.nl/zs/3b6c95f9-3ec3-40e3-888a-f254865ef2a9,http://cleanlease.nl/zs/c6a354ca-dc2e-48ae-9975-a59c190b507b" } } } }

Now when I lookup the resource identified under “resourceInventoriedAs” (01FDV09AEM1QTFQ8EYBBPT67NP):

{ "data": { "economicResource": { "containedIn": null, "currentLocation": { "id": "01FDSM9TTCHXM5AEDBX0AX327Y" }, "id": "01FDV09AEM1QTFQ8EYBBPT67NP", "name": "Gown Lot", "note": "Manifest: http://cleanlease.nl/zs/0471b80b-0301-4aa5-92d0-6a1de73239be,http://cleanlease.nl/zs/3845418d-cdf2-4cd1-81b9-90c783d0fdd1,http://cleanlease.nl/zs/3b6c95f9-3ec3-40e3-888a-f254865ef2a9,http://cleanlease.nl/zs/c6a354ca-dc2e-48ae-9975-a59c190b507b", "onhandQuantity": { "hasNumericalValue": 0 }, "primaryAccountable": { "id": "01FDSF07W22B3TMYF9HB2RG0QR", "name": "clean lease a_tsc" } } } }

I would expect that the primaryAccountable is the hospital (OLVG) after the transfer, not clean lease a_tsc (the provider)… Which is a problem because when I try to consume this lot resource as the hospital, I get the error:

“You cannot do this since the provider is not accountable for the resource.”

It seems to me that the agent is not updated to be the receiver after a transfer.

vcuculo commented 3 years ago

Interested on this issue. From API Tour documentation, there are 3 different cases for createEconomicEvent:

The first one, does not create new EconomicResources and should not change the ownership, but just decrease the available quantity. The second one, creates a new EconomicResource from scratch. The third one, creates a new EconomicResource (held by the receiver) by decreasing the quantity of an already existing resource (held by the provider).

fosterlynn commented 3 years ago

@vcuculo (and @sbocconi this helps answer your question above too about transfers creating a new resource)

creates a new EconomicResource from scratch

There is an additional part of this definition. produce and transfer might create a new EconomicResource from scratch. Or they might increment an existing EconomicResource on the receiver side. The latter happens when the resource is a "stock" resource that already exists, where each thing is "substitutable" for any other thing in the resource, like "3-1/4 in. 16-Penny Smooth Vinyl-Coated Steel Sinker Nails". In this case, the EconomicResource is not about which exact nails are in it, nails will come and nails will go, but it is considered the same resource.

More info here https://valueflo.ws/introduction/resources.html#identification-and-behaviors-of-resources.

(I know this wanders off topic of this specific issue, please ignore if not relevant to you.)

sbocconi commented 3 years ago

Hello @fosterlynn, so in case a EconomicResource is of type serialized (like a particular guitar) and I tranfer it from me (the owner) to you, is it correct that a new resource is created?

This does not sound logical to me if we want to perform track and trace, because it looks as it is more difficult to connect different resources to the same object, but there might be reasons that escape me. Could you elaborate on it please?

jaromil commented 3 years ago

@sbocconi for authenticated track and trace the Reflow the UID is changing at every interaction, aggregating each agent and event and resource connected. The change of state however should not invalidate previous connections, its just that a new resource is created connected to its previous state.

sbocconi commented 3 years ago

Hi @jaromil, and is this UID is different from the one reported by ResourceInventoriedAs (which stays constant, as seen e.g. in https://github.com/dyne/reflow-os/issues/3#issuecomment-923876363 )?

Is this UID more "internal" with respect to the id of ResourceInventoriedAs?

jaromil commented 3 years ago

@sbocconi yes and is not yet fully implemented yet, its the cryptography validator for track and trace once reflow is fully implemented and hopefully aligns with the logic of valueflows