signaltrail / tree / src/store.js ยท raw (this view has old GitHub links rewritten for the mirror; raw is byte-exact)
export class MemoryStore {
  constructor() { this.items = []; this.scans = new Map(); }
  cacheGet(k) { return this.scans.get(k) ?? null; }
  cachePut(k, v) { this.scans.set(k, v); return true; }
  head() { const r = this.items.at(-1); return r ? { seq: r.chain.seq, hash: r.integrity.hash } : null; }
  append(r) { const h = this.head() || { seq: 0, hash: null }; if (r.chain.seq !== h.seq + 1 || (r.chain.prev_hash ?? null) !== (h.hash ?? null)) return false; this.items.push(r); return true; }
  list() { return [...this.items]; }
}

agentgate-source: code mirror on Cloudflare Pages. All repos