MCPcopy Create free account
hub / github.com/EvoMap/evolver / _writeLedger

Function _writeLedger

src/atp/atpTaskPickup.js:63–79  ·  view source on GitHub ↗
(ledger)

Source from the content-addressed store, hash-verified

61}
62
63function _writeLedger(ledger) {
64 try {
65 const dir = getMemoryDir();
66 if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
67 const entries = Object.entries(ledger.spawned || {});
68 if (entries.length > LEDGER_MAX_ENTRIES) {
69 ledger.spawned = Object.fromEntries(entries.slice(-LEDGER_MAX_ENTRIES));
70 }
71 const tmp = _ledgerPath() + '.tmp';
72 fs.writeFileSync(tmp, JSON.stringify(ledger, null, 2));
73 fs.renameSync(tmp, _ledgerPath());
74 } catch (_) {
75 // Non-fatal: next tick will re-read Hub state. Stale ledger at worst
76 // causes a duplicate spawn, which the Hub will 409 on already-completed
77 // tasks without side effects.
78 }
79}
80
81function _isEligible(task) {
82 if (!task || typeof task !== 'object') return false;

Callers 2

pickOneFunction · 0.70
forgetFunction · 0.70

Calls 2

getMemoryDirFunction · 0.85
_ledgerPathFunction · 0.70

Tested by

no test coverage detected