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

Empty questions cause misbehaviour/Pointer glitches #11

Open
rmoehn opened this issue Jun 28, 2018 · 4 comments
Open

Empty questions cause misbehaviour/Pointer glitches #11

rmoehn opened this issue Jun 28, 2018 · 4 comments

Comments

@rmoehn
Copy link
Contributor

rmoehn commented Jun 28, 2018

Exhibit 1:

What is your root question?
> <Enter>
Question: [$1: ]
Scratchpad: [$1: ]
Subquestions:

>

Exhibit 2:

What is your root question?
> What is the capital of Assyria?
Question: [$1: What is the capital of Assyria?]
Scratchpad: [$2: ]
Subquestions:

> ask<Enter>
Question: [$1: What is the capital of Assyria?]
Scratchpad: [$q1: ]
Subquestions:
1.
  [$q1: ]
  $a1
  $w1

> unlock $a1
Question: [$1: ]
Scratchpad: [$1: ]
Subquestions:

>
  • Question and scratchpad shouldn't have the same pointer.
  • Empty questions don't make sense, so I would just forbid them.

I could probably fix this easily, but I don't want to switch context now. Besides, this is a good bug to fix for someone who wants to get to know the codebase.

@rmoehn rmoehn changed the title Empty root question causes misbehaviour Empty questions cause misbehaviour Jun 28, 2018
@rmoehn rmoehn changed the title Empty questions cause misbehaviour Empty questions cause misbehaviour/Pointer glitches Jul 19, 2018
@rmoehn
Copy link
Contributor Author

rmoehn commented Jul 19, 2018

Another glitch with the scratchpad:

What is your root question?
> Is [] the empty list?
Question: [$1: Is [$2: ] the empty list?]
Scratchpad: [$2: ]
Subquestions:


>

I guess some implementation detail causes null pointers ([]) to always appear unlocked.

Here is yet another glitch:

What is your root question?
> What is the air-speed velocity of an unladen swallow?
Question: [$1: What is the air-speed velocity of an unladen swallow?]
Scratchpad: [$2: ]
Subquestions:


> ask What is the air-speed velocity of an unladen African swallow?
Question: [$1: What is the air-speed velocity of an unladen swallow?]
Scratchpad: [$2: ]
Subquestions:
1.
  [$q1: What is the air-speed velocity of an unladen African swallow?]
  $a1
  $w1

> unlock $a1
Question: [$1: What is the air-speed velocity of an unladen African swallow?]
Scratchpad: [$2: ]
Subquestions:


> reply []
Question: [$1: What is the air-speed velocity of an unladen swallow?]
Scratchpad: [$2: ]
Subquestions:
1.
  [$q1: What is the air-speed velocity of an unladen African swallow?]
  [$a1: [$2: ]]
  $w1

> scratch []
Question: [$1: What is the air-speed velocity of an unladen swallow?]
Scratchpad: [$a1: [$2: ]]   <===
Subquestions:
1.
  [$q1: What is the air-speed velocity of an unladen African swallow?]
  [$a1: [$2: ]]
  $w1

>

This is caused by the data deduplication and might confuse a user.

@rmoehn
Copy link
Contributor Author

rmoehn commented Jul 21, 2018

But since Patchwork is not intended for end users, this issue is probably unimportant.

@stuhlmueller
Copy link
Member

I don't think it's obviously unimportant. Identifying pointers (for the purpose of unlocking within a workspace) that have the same contents, but were created independently, feels like a symptom of a design choice that might be incorrect.

@rmoehn
Copy link
Contributor Author

rmoehn commented Jul 24, 2018

Okay, here is my analysis, then.

Example:

What is your root question?
> Bat?
Question: [$1: Bat?]
Scratchpad: [$2: ]
Subquestions:


> scratch Bat?
Question: [$1: Bat?]
Scratchpad: [$1: Bat?]
Subquestions:


>

The steps are roughly:

  1. Insert the root question into the database. It gets address A1.
  2. Scratch.act inserts ‘Bat?’ into the database (TransactionAccumulator.insert). The content is already in the database, so new_scratchpad_link will be A1 as well.
  3. Scratch.act constructs a successor workspace with A1 as both the question link and the scratchpad link.
  4. Scratch.act constructs a successor context pointing to that workspace.
  5. The context has to contain a dictionary that maps pointers to addresses and a dictionary that maps addresses to pointers. These mappings are bijective, ie. every pointer is mapped to exactly one address and vice versa. Context.__init__ calls Context._name_pointers to construct these mappings.

In the example above, there is only one address A1, which _name_pointers maps to $1. This is how we end up with the same pointer in the scratchpad and the question, even though they were ‘created independently’.

_name_pointers creates mappings for the sub-question pointers (question, answer, workspace) first, which is how we end up with Scratchpad: [$a1: [$2: ]] in the last example above.

How could we fix this? Options:

  • Map multiple pointers to one address. In the reverse we would then have to map one address to multiple pointers.
  • In Datastore.insert: Never return an address twice. Instead, when the content is already present, return an alias.
  • Give up on the deduplication and content-addressability, and just create a new record and a new address for every insertion into the datastore.

I haven't thought through the consequences of these options, yet.

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

No branches or pull requests

2 participants