Skip to content

Re-asking a locked-pointer question causes endless loop #15

@rmoehn

Description

@rmoehn

Don't try to understand the title. Look at this scenario instead:

What is your root question?
> Who wrote Gödel, Escher, Bach?
Question: [$1: Who wrote Gödel, Escher, Bach?]
Scratchpad: [$2: ]
Subquestions:

> ask $1
Question: [$1: Who wrote Gödel, Escher, Bach?]
Scratchpad: [$2: ]
Subquestions:
1.
  [$q1: [$1: Who wrote Gödel, Escher, Bach?]]
  $a1
  $w1

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

> ask $1
[Goes into endless loop.]

The same happens with sub-questions of sub-questions.

The endless loop occurs in Context.is_own_ancestor:

    def is_own_ancestor(self, db: Datastore) -> bool:
        initial_workspace = db.canonicalize(self.workspace_link)
        context: Optional[Context] = self.parent
        while context is not None:
            if context == self and db.canonicalize(context.workspace_link) == initial_workspace:
                return True
            context = context.parent
        return False

Apparently the context has become its own ancestor, so context.parent never is None.

Of course it doesn't make sense to re-ask a context's question, so patchwork should detect this kind of scenario and raise an error. More concretely: Raise an error if the argument to AskSubquestion is a pointer to the current context's question.

This is related to issue #12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions