MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / ss_sweep_run

Function ss_sweep_run

tests/test_store_scope.c:253–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251
252typedef struct { bool setup, open, success, cancelled, hidden, restored; uint64_t calls; } ss_sweep_result_t;
253static ss_sweep_result_t ss_sweep_run(uint64_t trip) {
254 ss_sweep_result_t out={0}; cbm_store_t *s=cbm_store_open_memory(); ss_ids_t id={0}; ss_cancel_t cancel={0};
255 out.setup=ss_seed(s,&id);
256 for (int i=31;out.setup && i>=0;i--) {
257 char name[48]; (void)snprintf(name,sizeof(name),"fan_%02d",i);
258 int64_t node=ss_node(s,name,100+i);
259 out.setup=node>0 && ss_edge(s,node,id.root,"CALLS");
260 }
261 cbm_store_read_scope_t *scope=NULL; cbm_impact_walk_t *walk=NULL;
262 int rc=out.setup?cbm_store_read_scope_open(s,ss_cancel,&cancel,&scope):CBM_STORE_ERR;
263 out.open=rc==CBM_STORE_OK;
264 cancel.calls=0; cancel.trip=trip; cancel.armed=trip!=0;
265 if (rc==CBM_STORE_OK) rc=cbm_impact_walk_open_scoped(scope,&ss_policy,&walk);
266 int64_t sinks[4]={id.z,id.tail,id.z,id.tail};
267 if (rc==CBM_STORE_OK) rc=cbm_impact_walk_add_sinks(walk,sinks,4);
268 int64_t seeds[4]={id.root,id.root,id.root,id.root};
269 if (rc==CBM_STORE_OK) rc=cbm_impact_walk_run(walk,seeds,4);
270 if (rc==CBM_STORE_OK) rc=cbm_impact_walk_run(walk,&id.island,1);
271 out.calls=cancel.calls;
272 out.success=rc==CBM_STORE_OK && walk && cbm_impact_walk_count(walk)==38 &&
273 cbm_impact_walk_reached(walk,id.root) && cbm_impact_walk_reached(walk,id.tail);
274 if (trip) {
275 /* Stop asserting the predicate, then require the operation's latch to persist. */
276 cancel.armed=false; cancel.stop=false;
277 out.cancelled=rc==CBM_STORE_CANCELLED && scope && cbm_store_read_scope_check(scope)==CBM_STORE_CANCELLED;
278 out.hidden=walk?ss_hidden(walk,id.root):rc!=CBM_STORE_OK;
279 }
280 if (walk) { cbm_impact_walk_close(walk); }
281 int closed=ss_scope_close(scope);
282 out.restored=out.open && closed==(trip?CBM_STORE_CANCELLED:CBM_STORE_OK) &&
283 sqlite3_get_autocommit(cbm_store_get_db(s)) && ss_integer(s,"PRAGMA query_only",0) && ss_integer(s,"SELECT 1",1);
284 cbm_store_close(s); return out;
285}
286TEST(store_scope_counter_sweep_never_exposes_a_cancelled_prefix) {
287 ss_sweep_result_t control=ss_sweep_run(0);
288 ASSERT_TRUE(control.setup); ASSERT_TRUE(control.open); ASSERT_TRUE(control.success); ASSERT_TRUE(control.restored);

Callers 1

test_store_scope.cFile · 0.85

Calls 15

cbm_store_open_memoryFunction · 0.85
ss_seedFunction · 0.85
ss_nodeFunction · 0.85
ss_edgeFunction · 0.85
cbm_impact_walk_runFunction · 0.85
cbm_impact_walk_countFunction · 0.85
cbm_impact_walk_reachedFunction · 0.85
ss_hiddenFunction · 0.85

Tested by

no test coverage detected