Are you aware of qlf (Quick Load File) file type?
Are you aware of library(persistency): Provide persistent dynamic predicates?
Are you aware of plt (Polog Test File).
As I don’t know the exact details or your problem, these are just concepts to look at that are not commonly known.