Page MenuHomePhabricator

Hard coded check for Z2/Persistent object
Closed, ResolvedPublic

Description

Implement a checker for stored ZObjects.

Every top-level ZObject stored in WikiLambda must have the type Z2/Persistent object.

(Optional: and only top-level ZObjects stored in WikiLambda may be of type Z2/Persistent object).

A Z2/Persistent object must have the following four keys and respective values (and only these for now):

Z1K1/type with the value "Z2" for Persistent object.

Z2K1/ID. The value of this must be a string that is the same as the page name. It must be of the format Zn with n being a natural number.

Z2K2/value. The value of this must be a well-formed ZObject.

Z2K3/label. For now we start with this being a simple string. This will be turned into a multilingual label very soon.

Event Timeline

DVrandecic raised the priority of this task from Medium to High.Aug 13 2020, 12:43 AM

We should talk about whether we really want to store the Z2K1 in the JSON blob, as opposed to simply providing access to it.

Change 619281 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/WikiLambda@master] [WIP] Show a header on each ZPersistentObject page

https://gerrit.wikimedia.org/r/619281

It was so useful in Wikidata to store the QID in the blob, for easier processing of the dumps and usage of the raw content by external parties, which is why I like it to be stored here.

It was so useful in Wikidata to store the QID in the blob, for easier processing of the dumps and usage of the raw content by external parties, which is why I like it to be stored here.

Yes, but it means a possibility of the data being inconsistent (Z1234 thinks it's Z1235; who is right?).

It means that when we create the object (before initial save), we will have an invalid structure (and a bunch of code thus needs to know if this is valid-as-long-as-we've-not-saved-yet vs. actually-invalid), that we then correct at the last moment to insert the Z2K1 key (and potentially have a bit of a DB deadlock).

It means that we're going to have the same issues that Wikidata does around moving (re-numbering) objects, which is probably fine but another loss.

We can always inject it into the JSON object for API access and export purposes; adding a "getRawObject()" method and inserting it there would be pretty trivial.

Yup, we could "fix" this by making pages non-deletable (or at least, non-undeletable) as well as non-movable on Wikidata, but I'm really keen to avoid the issues.

OK, those are good arguments (I particularly was convinced by the object creation issue).

But being able to point to yourself is still a useful feature that the data model relies upon for providing identity for types, functions, booleans, and other enum-like objects. And they would have the same issue.

Brainstorming a solution: in the raw stored issue we introduce a "magic" word which gets replaced by the page title for further processing and when exposed to the outside world.

The magic word could be something like Z0 (as this is can be statically detected and already has a built-in escape mechanism and has no language bias) or IDENTITY (and we could use the same escape mechanism, in fact, but it would have the problem that it would be read as a string unlike Z0). Or something else. Please not T_PAAMAYIM_NEKUDOTAYIM.

The escape mechanism is that we don't touch it if it is the value of a Z6K1.

So my suggestion would be to store Z2K1: Z0 here, and then create new tasks to provide the shim between the internal representation and the external one.

(Which is a good idea anyway, instead of just using the raw content).

Open to other solutions. If it was only Z2K1, we could just hardcode the injection of this key-value pair, but as said, the same is true for other keys later such as Z4K1 - and these may become complex.

Change 619281 merged by jenkins-bot:
[mediawiki/extensions/WikiLambda@master] Show a header on each ZPersistentObject page

https://gerrit.wikimedia.org/r/619281

Decision from meeting:

Let's implement the Z0 solution and add this already for this task.

There will be a new task to provide a view that replaces the Z0 with the page name, and can do other changes to the value at a later point. A new task for this will be created.

Change 621572 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/extensions/WikiLambda@master] [WIP] ZPersistentObject: Require Z2K1 (id) and Z2K3 (label) to be set

https://gerrit.wikimedia.org/r/621572

Change 621572 merged by jenkins-bot:
[mediawiki/extensions/WikiLambda@master] ZPersistentObject: Require Z2K1 (id) and Z2K3 (label) to be set

https://gerrit.wikimedia.org/r/621572

DVrandecic claimed this task.