Skip to content

perf(api): the epistemic snapshot is quadratic and re-reads six ledgers on every call #1410

Closed

Description

@DecisionNerd

Problem

Two compounding problems in one function, found independently by two readers.

epistemic_snapshot in crates/graphforge-api/src/epistemic_snapshot.rs:

  1. Is O(assertions times ledger sizes) on every read.
  2. Separately re-reads six full ledgers from disk on every call.

It runs on read-only paths, including belief-projection and valid-time queries.

Acceptance criteria

  • The snapshot does not re-read ledgers already read in the same operation.
  • The quadratic term is removed or justified in writing.
  • Measured: time and bytes read per call, before and after, against two project sizes with differing assertion counts.
  • Epistemic semantics, belief projection and valid-time results unchanged.

Relationships

Found by the second redundancy sweep under #1387's directive. Third of eleven findings by frequency times cost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions