-
Notifications
You must be signed in to change notification settings - Fork 17
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
Resolve TD/Thing ID Semantics (was Reconsider @type ThingID) #190
Comments
I think the original reason for adding this was to associate |
So I am not exactly sure if I understand the comment above but the |
Let's look at the following TD: {
"@context": "https://www.w3.org/2019/wot/td/v1",
"id": "urn:dev:ops:32473-WoTLamp-1234",
"title": "MyLampThing",
"securityDefinitions": {
"basic_sc": {"scheme": "basic", "in": "header"}
},
"security": "basic_sc"
} In compact form: {
"@id": "urn:dev:ops:32473-WoTLamp-1234",
"http://purl.org/dc/terms/title": "MyLampThing",
"https://www.w3.org/2019/wot/td#hasSecurityConfiguration": {
"@id": "basic_sc"
},
"https://www.w3.org/2019/wot/td#securityDefinitions": {
"@index": "basic_sc",
"https://www.w3.org/2019/wot/td#in": "header",
"https://www.w3.org/2019/wot/td#scheme": "basic"
}
} The (If the To my understanding, two nodes cannot have the same identifier in a single domain, not just in a directory. Now, looking at the ontology here, From the TD spec:
To me, the above clearly states that (If Thing refers to the device and not the TD, then the TD should not be called a Thing) |
I agree with @farshidtz explanation. Besides, from the RDF perspective I think it makes more sense to rely on the xsd type (anyURI); which is actually the one used in the Thing spec for describing the form of such id (without actually specifying the ThingID rdf:type). I do not see the necessity of defining such type, could you provide more details about it?. If we define the type ThingID, are we going to define an rdf: type as well for any input that the API has ? e.g., SparqlQuery for the query parameter? |
As I have said before, for various reasons we should avoid making the ID used to look up a record in a directory necessarily the same as the value of the "id" field in each record. These reasons include:
That said, it can be permitted that the local ids may be the same as the "id" field in the Thing, if the implementation choses to do so. But for 2 and 3 at least we will have to make some exceptions. BTW 2 is also why we need a different action for "create" and "update"; so we don't confuse a new Thing trying to register itself with another Thing that (because the dev was lazy) has the same id. Note that 2 means the dev is not complying with the TD spec, but I'd rather see the system be resilient than pedantic. Anyhow, if we call this a "LocalThingID" then we can simply make the statement somewhere that "This may but is not guaranteed to be the same as the internal Thing "id" field." and confusion is avoided. PS: for 1, I could imagine a directory implementation having an installation option that the user can select that would always give directory records unique IDs unrelated to the "id" field... |
@mmccool From JSON-LD spec:
As stated, the id is used to uniquely identify the node objects. These objects will at least co-exist in listing, notification, search results and so the ids must be unique. Regarding point 2, the current HTTP API does not allow creating two Things with the same id. A second attempt to create using the same PUT
Yes, but the Thing id should still stay unique. Apart from the requirement coming from Linked Data specs, having duplicate IDs conflicts with the functionalities of all listing, notification, and search APIs. An implementation can work around this by offering isolated namespaces for registration, search, notification APIs, e.g.:
Not sure this will help: we can still have multiple Thing Links (the new type added in discovery) with unique ids pointing to the actual Thing, all in the same directory. Back to the actual topic: I think calling it @AndreaCimminoArriaga |
Some remarks:
TD is already not called a Thing? If you mean that the
I need someone who has precise information on the history of the standardization but here is what I remember: The It is perfectly ok that two TDs have the same |
I'm really not sure anymore. I also had the opinion that they are distinct (#133 (comment)) but was convinced otherwise. We recently had this discussion before changing affordance names and directory API paths to use "thing" instead of "td". For start, the section that described the TD class is called "Thing". Again,
In my opinion, the history behind it doesn't matter much. What matters is that the In realistic settings, it is very easy to guarantee unique IDs in virtual resources. But it is almost always the case that heterogenous physical devices will end up having colliding IDs, even is small-scale environments. Not every manufacturer is going to follow a scheme guaranteeing unique IDs. But it is very easy to make sure TDs that have unique IDs and then refer to those physical devices. I think taking a physical device ID and directly using it as the identifier of a TD in the world wide web of things is fundamentally flawed. |
So Ege's point has me worried:
Use case: different TDs for local/remote access; local TDD; both TDs wanted in TDD In conclusion: different TDs can have different views of the same entity (the Thing). |
From the RDF perspective, and thus this applies for the tags '@id' or 'id' since they are equivalent (the @content manages this equivalence, two TDs can not have the same id if they are stored in the same TDD. This is due to the fact that two resources can not have the same id in RDF. I think this makes sense since two TDs referring to the same Thing offer two different views or realities of the same Thing. However, I agree that these relationships should be somehow present in the TDs. As a solution we could extend the discovery context (although the place to do this extension is in the Thing Description context) and add a property that points to an id that is the Thing id. Giving an example of two TDs referring to the same Thing:
Nevertheless, according to RDF the resources that have an id must be accesible and provide data therefore if we add the id of the Thing who is going to provide or host the Thing data? is this just an id that will not provide any further data? if this is the case the Thing id will act like a MAC address, it will just be a literal property (a string). Depending on this the new property will be a data property or an object property. Besides this solution, I agree with a comment of @egekorkan. It is a bit confusing that the type of these documents is Thing when they should be actually called Thing Descriptions since there is another entity that is the actual Thing. If I'm not mistaken in the past the type of the description was ThingDescription, which could leave space for adding a reference to a different entity that has a type Thing. Summing up, adding a tag in the json that points to the id of the Thing it is a easy-fix solution that should be implemented in the Thing Description @context. It must be modelled as a data property (literal) if this id is not going to provide further data, or as an object property if this Thing entity will provide data (but in this case having only Thing as type will be confusing). |
@mmccool
If id is really about the underlying physical/virtual entity, then why is it tied to the TD using the |
Discussion: |
Let's continue to discuss here, and discuss the implications of either choice (id of TD or Thing) and how to fix the "other" use cases with both choices. |
As mentioned during the meeting, I think that the whole problem is due to the fact that there are two entities in the whole discussion: ThingDescription and Thing. A Thing is a physical device and the ThingDescription is a "view" that describes such Thing. Now, there is a relationship bertween these entities a Thing can clearly have one or more ThingDescriptions (I'm not sure if it makes sense to say that a Thing may have zero). In addition, we know that a Thing has at least one attribute, which is the id, that must uniquely identify the device. The problem, for me, is due to the fact that these two entities are not present in the specification. As @farshidtz previously explained, the spec defines only one entity that is the Thing. This Thing nevertheless is a ThingDescription and not the Thing itself. So the clear solution would be to introduce a new entity in the ontology and the thing description model, so to have the classes @type Thing and @type ThingDescription. Following this approach we could easily define multiple ThingDescriptions, each of which have different ids, that refer to the same Thing. Let's imagine we have a Thing that is a Lamp, and we want to define three ThingDescriptions that point to the same Lamp (the id of the lamp will be
Notice that the last ThingDescription is an anonymous one, its id is not specified (and thus it should be a blank node in RDF or the Directory should inject a local id). Nevertheless, it is possible to find any ThingDescription that is related to the same Thing regardless of its id with any search (JSONPath, XPath, and SPARQL). A less elegant, but that require fewer changes in the spec, would be to define a property that points to the thing id (but this solution is not very align with the RDF principles). The previous examples would look like
The first solution entails defining the classes ThingDescription and Thing, and an object property that relates them. The second is just adding a data property to the current Thing. Nevertheless, the first solution allows defining more properties to the Thing (not to the ThingDescription which is already fine) and could be useful for combining the current Ontology with others like SAREF. If the ThingDescription is a view and not the Thing itself, the type "saref:Light" should be assigned to the Thing and not to the ThingDescription. |
Unfortunately, I think we want a compatible solution so it can go into the TD 1.1 spec. During the F2F (on Oct 28, during the T2TRG/DID session) the idea of using "fragment identifiers" on IDs came up. I need to think more/research more about this, but this is an outline or my thoughts:
Examples:
I'm a little concerned that fragment identifiers may not have the right semantics, since we are not talking about a part of a document but a view, and also may conflict with other usages, i.e. using JSONPointers to reference a part of a TD (if the ID is an actual URL pointing at a Thing, for instance). So I think the second alternative above, using a named "view" query parameter, is safer. BTW both "version" and "variant" have special meanings for UUIDs so I think we should avoid those terms to avoid confusion. |
Note: fragment identifiers on DIDs may actually make some kind of sense if (a) they refer to the DID document (b) the DID document lists all the variant TDs ("views") (c) we can use a fragment id to extract the one we want. This does however require the DID document to be updated whenever we "publish" a new view, however, which seems like a nuisance, and doesn't work anyway if we are not using DIDs to refer directly to TDs but to directories. I still think in other contexts fragment identifiers are not quite the right thing to do and a query parameter would be safer. Ideally we would track down a best practices recommendation in this area (e.g. for UUIDs), though. |
Yes the only reason for this annotation is to give Consumers a hint that the id uri variable can be used to identify a thing across different interaction affordances, e.g. the same id used to create a Thing can be used to remove it. There's otherwise no way to express this kind of relationship in a Thing Description. Hopefully we don't have to rely on Consumers correctly interpreting this hint though, since they'll be implementing what it says in the prose of the specification anyway.
I can't help but feel this whole discussion is getting hung up on RDF semantics and overcomplicating something which is really quite simple. Every Web Thing is either a virtual thing (where a physical Thing doesn't really exist) or a virtual abstraction of a physical Thing in the real world. Either way a Consumer can only ever interact with that virtual Web Thing abstraction, not the atoms of the physical object in the real world. Therefore as far as a WoT Consumer is concerned, the Web Thing is the Thing and the Thing Description is a JSON representation of that Thing on the web. I can't think of any practical reason that you would need to be able to identify the Thing, Web Thing or Thing Description separately. Yes, you could have two different Thing Descriptions for the same Thing each with its own URL, but as far as a WoT Consumer is concerned they should be treated as two separate Web Things. The fact that they describe the same physical device is really irrelevant at this layer of abstraction. If you have two identical web pages which are hosted from two different URLs then as far as a web browser is concerned they are two different web pages. The fact that two web pages contain the same information or describe the same subject matter doesn't make them the same web page. Granting a permission to one origin does not grant it to another. Being authorised to access one web page does not mean you are authorised to access the other. Caching one of the pages does not cache the other. We actually have this situation in WebThings since for practical reasons every Web Thing hosted by WebThings Gateway has two separate URLs: a local one (e.g. http://gateway.local/things/foo) and a remote one (https://bar.webthings.io/things/foo). This URL is used as the id member of the Thing Description and is considered to be the URI of both the Thing Description and the Web Thing it describes. But as far as an external Consumer is concerned http://gateway.local/things/foo and https://user.webthings.io/things/foo are two completely separate entities since they have different URIs and come from two separate origins.
I personally also think this is overcomplicating things and it's fine if a directory implementation wants to use the IDs from Thing Descriptions as identifiers in the directory. There are workarounds for edge cases. |
Interesting find at architecture document at https://w3c.github.io/wot-architecture/#intermediaries:
It is even a normative assertion, yay! |
Good catch. However that assertion itself is ambiguous. First, it says "an identifier" so it could be an arbitrary field such as the ThingID suggested by Andrea and not necessarily the |
Discussion (from 8 Nov meeting)
|
It seems to me that this discussion is based on wrong premises. TL;DR:
The first sentence is right but I don't see how you get to conclude that There are guidelines for that, "Cool URIs for the Semantic Web", observing that:
What these guidelines specify are 2 ways to make the distinction:
One example of each:
In some occasion, it is useful to describe both entities in the Web document, that's why schema.org has {
"id": "urn:dev:ops:32473-Thing-123",
"schema:mainEntityOfPage": ""
} where In fact, I used this mechanism in an early TDir implementation: metadata about the TD (such as registration time and publisher) is stored in a separate document, which links to the TD with |
@benfrancis it's not obvious to me how a Web Thing and a TD are different entities. In the Web Thing API, the term "Web Thing" is never used alone and what is being specified is a (Web) Thing Description. As far as I'm concerned, I can conceptualize WoT with the concepts of "Thing" and "TD" alone. Where can the concept of "Web Thing" help? (This isn't a rhetorical question.) |
@vcharpenay wrote:
That's correct, in WebThings we don't distinguish between the two. The Thing Description is a JSON representation of the Web Thing resource and both are identified by the same URI. Just for the purposes of this conversation about what
Using the terminology above, the WebThings WoT consumer implementation only cares about Web Things (of which a Thing Description is one representation), they don't care about whether that Web Thing represents a physical Thing or not. The same URI (e.g.
I get that some people might want to include an identifier of the real physical object (such as a serial number) in a Thing Description too, but maybe that should just be additional product metadata, not the I'm not going to try and argue against any of the rationale regarding best practices on the semantic web, I'm sure you're right. But please understand I'm speaking from the point of view of the WebThings implementation which doesn't parse Thing Descriptions as RDF, it parses them as plain JSON and doesn't use any semantic web technologies. I understand that other implementations do parse Thing Descriptions as JSON-LD/RDF and that it has to make sense to them too, but I would be disappointed if that means we have to have three separate URIs for:
From my point of view ideally all three could be the same URI, but I accept that in some implementations 1 and 2 are already different. This whole conversation seems to have been sparked by me adding |
OK, thanks. Isn't a Web Thing a (particular case of) Servient, then?
vs.
|
Sure. Most implemetations do see TDs as plain JSON, I'm sure. But to me, the question of identification is orthogonal to whether a TD is parsed as JSON or RDF. It pertains more to the general architecture of the Web and URIs. An When a TDir uses this I'd therefore suggest to keep these 2 identifiers and to clarify somewhere in the WoT discovery specification what they identify (Thing vs. TD) and how to use them. |
@vcharpenay wrote:
My take on this is that the web resource is the Web Thing and a Thing Description is one representation of that resource. It may have other representations like HTML. The Web Thing, Thing Description and HTML web page can/should therefore have the same URI. When adding a Web Thing to a directory however, things are a bit different since you are really creating a new web resource...
Ah, OK. I see the problem. For the record, the way that WebThings Gateway's directory API (which predates WoT Discovery) deals with this is to treat the Thing Description hosted in the gateway's directory as a new Web Thing with a new ID. For example:
Other directories may well work differently to this because WebThings Gateway isn't just a directory which provides a repository of Thing Descriptions, it's a gateway which proxies Web Things to another network and creates a whole new Thing Description with a new URL, new ID and even a new set of Forms with new endpoint URLs. This means that a Web Thing on the local network like The above is why I say that ideally the URL of the Thing Description, the As far as the original topic of this issue is concerned, the important thing is that a client of the Directory Service API knows that the URL specified in the PUT request to add a Thing to the directory can then later be used to retrieve (GET), update (PUT/PATCH) or delete (DELETE) the same Thing. The example Thing Description provided in Section 8.2 is non-normative and the |
So to follow up on this, we decided to remove the arch-id-correlation assertion (see wot-architecture PR #768). At this point we probably have to defer a resolution to this to TD 2.0/Discovery 2.0, so I'm going to keep the issue open but mark it as deferred. Eventually we should follow up on some of the ideas above, i.e. using fragment identifiers to distinguish TD variants, follow best practices for RDF and the web URIs, etc. |
I'll put back on the "Resolve by CR" label for now just so it will come up when we review these in a future Discovery call, when I hope we can confirm the decision to defer. |
OK, I'm not sure what the conclusion is here. Let's decide soon! |
Discussion: confirm decision to defer (discovery call 2022.9.5). |
#188 introduced
@type: ThingID
for identifiers inside a Thing Description Directory ( checkuriVariables
description below). During the 31/05 call, there were some comments about the fact that we are missing a proper definition for this new keyword. Moreover, we should clarify the differences betweenid
from TD ontology and these new terms. One proposal was to reword it asLocalThingID
referring to the fact that is just an id related to the directory.See:
The text was updated successfully, but these errors were encountered: