From a Git Bash shell in VS Code (note that the Unix-style $ prompt and the Windows version output are both correct):
$ swipl --version
SWI-Prolog version 9.3.36 for x64-win64
I first attempted to locate test cases for library(persistency) in the official SWI-Prolog GitHub repository, but was unable to find any. If such tests exist elsewhere, I would very much like to study them.
While creating multiple test cases that rely on a knowledge base built using library(persistency)—for example:
:- begin_tests(core_predicates,
[ setup(setup_isolated_kb),
cleanup(cleanup_isolated_kb)
]).
I have run into issues with sequential tests. Loading the persistent KB in one test can interfere with loading it in the next.
This made me wonder whether the KB-closing mechanism is contributing to the problem. Specifically, close_dbs/0 is not exported; it is only invoked via at_halt/1. Here is the relevant portion of the module:
:- module(persistency,
[ (persistent)/1, % +Declarations
current_persistent_predicate/1, % :PI
db_attach/2, % :File, +Options
db_detach/0,
db_attached/1, % :File
db_sync/1, % :What
db_sync_all/1, % +What
op(1150, fx, (persistent))
]).
close_dbs :-
forall(retract(db_stream(_Module, Stream)),
close(Stream)).
:- at_halt(close_dbs).
In previous projects, library(persistency) worked reliably for proofs of concept, so I never created dedicated tests. For this new project, however, proper test coverage is essential. The lack of existing test cases, combined with insights from Claude Code and human review suggests that I may be encountering edge cases that require guidance to resolve, or that library(persistency) itself may need some adjustments to better support test-driven workflows.
My goal is not to fix my specific code but to understand at a higher level what is the correct approach for testing when using library(persistency).