Q&A — Phase 17.1 TemporalGraph #435
Unanswered
web3guru888
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Q&A — Phase 17.1 TemporalGraph
Q1: Why
timestamp_ns: intinstead offloatfor timestamps?time.time_ns()returns anintwith nanosecond precision and no floating-point rounding error.floathas 53-bit mantissa precision (~15 decimal digits), which at nanosecond scale (18 digits) loses precision after ~10^4 seconds (~2.8 hours). Usingintalso enables exact equality checks and safe hash/freeze in thefrozen=Truedataclass.Q2: How is
AllenRelationenforced onadd_edge()? Is it validated against actual timestamps?In Phase 17.1,
AllenRelationis a label supplied by the caller — it is stored and exposed to downstream components but not re-derived from timestamps. The DAG constraint is enforced by cycle detection, not Allen semantics. A future improvement (17.5 TemporalOrchestrator) can add a consistency check: e.g. ifrelation=BEFOREthenfrom_node.timestamp_ns < to_node.timestamp_nsmust hold. This two-phase approach keeps 17.1 simple while leaving room for stricter validation.Q3: What is the time complexity of cycle detection? Is it acceptable at scale?
DFS cycle detection is O(V + E) per
add_edge()call. Formax_nodes=10_000and a sparse graph this is typically <1 ms in CPython. The check runs synchronously insideasyncio.Lock, so it blocks the event loop briefly. For very dense graphs (>100K nodes), consider: (a) raisingmax_nodeslimit only after profiling, or (b) switching to an incremental topological sort algorithm (O(log V) amortised per edge) in a future iteration.Q4: How does pruning interact with causal chains? Can we lose important history?
Wall-clock pruning (
timestamp_ns < horizon_ns) removes nodes regardless of whether they have successors. This is safe for recent-history use cases (EventSequencer, PredictiveEngine typically look back <1 hour). For longer-horizon causal tracing, two mitigations:prune_horizon_s(default 3600 s) inTemporalGraphConfig.tags=frozenset({"anchor"})) and extendprune()to skip anchored nodes.Q5: What is the concurrency model? Can multiple coroutines call
add_node()safely?Yes. Every mutating method (
add_node,add_edge,prune) acquiresasyncio.Lockbefore touching shared state. Because asyncio is single-threaded, there is no true parallelism —Lockprevents interleaving between coroutines atawaitboundaries. Read methods (get_successors,get_predecessors) also hold the lock to avoid torn reads during concurrent mutations.Q6: How does
TemporalGraphintegrate withWorldModel.update()from Phase 13?The recommended wiring:
This creates a linear causal chain through perception steps; branching edges are added when goals split or parallel paths emerge.
Q7: How do I build a Grafana timeline panel showing TemporalGraph events?
For a true timeline (event-by-event), export nodes to a time-series data source (e.g. InfluxDB or Loki) tagged by
node_idandtags.Full spec: Issue #434 · Show & Tell: Discussion #435 · Phase 17 Planning: Discussion #433
Beta Was this translation helpful? Give feedback.
All reactions