oughtinc / patchwork

Command-line recursive question-answering with immutable contexts and explicit data store
https://ought.org/projects/factored-cognition
MIT License
24 stars 1 forks source link

Asking root questions sometimes returns None when using store #4

Closed stuhlmueller closed 6 years ago

stuhlmueller commented 6 years ago

Example:

root@9478c75e88cc:/data# python -m patchwork.main store.db
What is your root question?
> what is the sum of list [[6] []]
That question has already been answered:
[[6]]

root@9478c75e88cc:/data# python -m patchwork.main store.db
What is your root question?
> what is the sum of list [[6] [[7] []]]
None

I'm attaching the zipped store.

store.db.zip

rmoehn commented 6 years ago

Here's a minimal example for reproducing the None:

Start: python3.6 -m patchwork.main new.db

What is your root question?
> what is the sum of list [[6] []]<Enter>

#

What is your root question?
> what is the sum of list [[6] []]
Question: [$1: what is the sum of list $3]
Scratchpad: [$2: ]
Subquestions:

> unlock $3<Enter>

#

Question: [$1: what is the sum of list [$3: $4 [$2: ]]]
Scratchpad: [$2: ]
Subquestions:

> reply 6<Enter>

#

The initial context was:
 Question: [$1: what is the sum of list $3]
Scratchpad: [$2: ]
Subquestions:

The final answer is:
 [6]

Restart 1

What is your root question?
> what is the sum of list [[6] []]<Enter>

#

What is your root question?
> what is the sum of list [[6] []]
That question has already been answered:
[6]

Restart 2

What is your root question?
> what is the sum of list [[6] [[7] []]]<Enter>

#

What is your root question?
> what is the sum of list [[6] [[7] []]]
None
> ask Why None?
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/erle/repos/patchwork/patchwork/main.py", line 37, in <module>
    main(sys.argv)
  File "/home/erle/repos/patchwork/patchwork/main.py", line 30, in main
    ui.cmdloop()
  File "/usr/lib/python3.6/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.6/cmd.py", line 217, in onecmd
    return func(arg)
  File "/home/erle/repos/patchwork/patchwork/interface.py", line 60, in do_ask
    return self._do("ask", AskSubquestion(arg))
  File "/home/erle/repos/patchwork/patchwork/interface.py", line 40, in _do
    result = self.session.act(action)
  File "/home/erle/repos/patchwork/patchwork/scheduling.py", line 239, in act
    resulting_context = self.sched.resolve_action(self.current_context, action)
  File "/home/erle/repos/patchwork/patchwork/scheduling.py", line 142, in resolve_action
    assert starting_context in self.active_contexts
AssertionError

Restart 1 is probably not necessary for reproducing the failure. The last query was just to see what happens.

rmoehn commented 6 years ago

Of course it would be tedious to type those commands over and over again during debugging. So here's a stupid-but-useful driver script that does the typing for us: https://gist.github.com/rmoehn/76ad05167f5e41197803f5fd5e6caac7

rmoehn commented 6 years ago

This unittest test might be even more useful than the driver.

That's it from me for today.