perf: streamline rule reads and unblock background discovery
This commit is contained in:
1 parent
b14fa2f4d1
commit
b17b975812
19 files changed
+263
-42
No files matched your search
@@ -11,6 +11,8 @@ function fixture(t){
|
||||
put(kind,item){if(!records.has(kind))records.set(kind,new Map());records.get(kind).set(item.id,structuredClone(item));return item;},
|
||||
transaction(work){transactionDepth++;try{return work();}finally{transactionDepth--; }},
|
||||
settings:()=>({processingEnabled,processingSince:null}),
|
||||
now:()=> '2026-10-23T02:00:00.000Z',clock:()=>new Date('2026-10-23T02:00:00Z'),
|
||||
schedule:()=>({times:['11:00','17:00'],weekends:false}),calendar:()=>[],intakeWindow:()=>null,
|
||||
snapshot(){snapshots++;return {window:{start:'2026-10-23T00:00:00Z',end:'2026-10-23T03:00:00Z',available:false}};},
|
||||
executionRule:record=>record?.draft,
|
||||
fields:()=>({samples:[],processes:[]}),discoveryBlockers:()=>[],
|
||||
@@ -32,10 +34,13 @@ test('one discovery set resolves its window once and registers every row before
|
||||
return {liveTodo:true,pdfExport:true};
|
||||
};
|
||||
await f.execution.scan({connectionId:'c1',idempotencyKey:'complete-discovery'},principal,{rows});
|
||||
assert.equal(firstProbe.snapshots,1,'the complete discovery set must use one window snapshot');
|
||||
assert.equal(firstProbe.snapshots,0,'discovery resolves its window without building a full store snapshot');
|
||||
assert.equal(new Set(firstProbe.tasks.map(task=>JSON.stringify(task.intakeWindow))).size,1,'all tasks must share the window resolved at scan start');
|
||||
assert.equal(firstProbe.tasks[0].intakeWindow.end,'2026-10-23T03:00:00.000Z');
|
||||
assert.equal(firstProbe.inTransaction,false,'external work must start after the discovery transaction');
|
||||
assert.equal(firstProbe.tasks.length,17,'all task rows must be committed before any probe or capture');
|
||||
assert.equal(firstProbe.targetCount,17);assert.equal(f.store.all('execution-tasks').length,17);
|
||||
assert.equal(f.snapshots,0,'capture absence checks and execution views must not assemble unrelated store snapshots');
|
||||
});
|
||||
for(const action of ['pause','stop'])test(`historical delivery drain yields before the second hint so an event-loop ${action} preserves pending work`,async t=>{
|
||||
const f=fixture(t);
|
||||
@@ -57,5 +62,6 @@ for(const action of ['pause','stop'])test(`historical delivery drain yields befo
|
||||
f.setProcessing(true);await f.execution.background();
|
||||
assert.equal(f.store.all('execution-discovery-runs').filter(item=>item.status==='complete').length,20);
|
||||
assert.equal(f.store.get('execution-discoveries','c1').status,'complete');
|
||||
assert.equal(f.snapshots,0,'background freshness checks must resolve only the schedule window');
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user