     ))
 
 (defn parent-data
-  "Find data with the given key recursively in parent(s) of the given context. 
+  "Find data with the given key recursively in parent(s) of the given context.
   Searches up in the context scopes until it finds data for the given key.
   Returns nil if no such data can be found"
   [context key]


(defn update-in-context
  "Update the application state by applying the given operation to the state of the component implied by
  the given context. Think of this as a 'targeted' `swap!` where you don't have to know where the data is 
  stored. This function also records the change in this state history with an optional associated Reason."
  [context operation undoable compressable reason]
  (let [application (-> context :application)


(defn- find-first [pred coll] (first (filter pred coll)))

(defn checked-index [items index id-keyword value]
    (let [index-valid? (> (count items) index)
          proposed-item (if index-valid? (get items index) nil)
         ]
     (cond (and proposed-item
                (= value (get proposed-item id-keyword))) index
           :otherwise (->> (map-indexed vector items) (find-first #(= value (id-keyword (second %)))) (first))
           )
     )
  )

(defn resolve-data-path [state path-seq]
  (reduce (fn [real-path path-ele]
            (if (sequential? path-ele)
              (do
                (if (not= 4 (count path-ele))
                  (logging/log "ERROR: VECTOR BASED DATA ACCESS MUST HAVE A 4-TUPLE KEY")
                  (let [vector-key (first path-ele)
                        state-vector (get-in state (conj real-path vector-key))
                        lookup-function (second path-ele)
                        target-value (nth path-ele 2)
                        proposed-index (nth path-ele 3)
                        index (checked-index state-vector proposed-index lookup-function target-value)
                        ]
                    (if index
                      (conj real-path vector-key index)
