001 (ns wildwood.knowledge-accessor
002 "The key point of building Bialowieza as a library rather than a complete
003 application is that it should be possible to hook it up to multiple sources
004 of knowledge. Thus we must design a protocol through which knowledge can be
005 accessed, and a schema in which it will be returned. Note that the
006 accessor must be able to add knowledge to the knowledge base, as well as
007 retrieve it."
008 (:require [wildwood.schema :refer [proposition?]]))
009
010 (defprotocol Accessor
011 (fetch [self id]
012 "Fetch all the knowledge I have about the object identified by
013 this `id` value, as a map whose `:id` key has this `id` value.
014
015 *NOTE THAT:* I now think knowledge should only be managed at the
016 Wildwood level as sets of propositions, so the idea of bringing
017 back some sort of object representation here is probably wrong.")
018 (match [self proposition]
019 "Return all the propositions I know which match this proposition. The
020 intended use case here is that you will either supply a fully
021 specified proposition to verify that that proposition is true, or else
022 supply a partially specified proposition to query.
023
024 e.g. passing the proposition
025
026 {:verb :kill :object :caesar}
027
028 would be a way of asking 'who killed caesar', and might return
029
030 [{:verb :kill :subject :brutus :object :caesar}
031 {:verb :kill :subject :cassius :object :caesar}
032 {:verb :kill :subject :longus :object :caesar}]")
033 (store [self proposition]
034 "Add this `proposition` to the knowledge I hold."))