---
title: "temporal"
description: "Temporal graph operations on Semantica — scoped queries at a point in time, graph snapshots, node change timelines, temporal causal analysis, and graph state reconstruction. Uses AgentContext.find_precedents(as_of=), ContextGraph.state_at(), CausalChainAnalyzer.trace_at_time(), and TemporalQueryRewriter. Sub-commands: query, snapshot, timeline, causal-at, precedents-at."
canonical_url: "https://skilld.dev/gh/semantica-agi/semantica/temporal"
last_updated: "2026-09-20T16:22:48.000Z"
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

---
name: temporal
description: Temporal graph operations on Semantica — scoped queries at a point in time, graph snapshots, node change timelines, temporal causal analysis, and graph state reconstruction. Uses AgentContext.find_precedents(as_of=), ContextGraph.state_at(), CausalChainAnalyzer.trace_at_time(), and TemporalQueryRewriter. Sub-commands: query, snapshot, timeline, causal-at, precedents-at.
---

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install semantica-agi/semantica/temporal`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/temporal`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/semantica-agi/semantica/temporal) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/temporal`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/temporal --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/temporal --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# /semantica:temporal

Temporal graph operations. Usage: `/semantica:temporal <sub-command> [args]`

`$ARGUMENTS` = sub-command + query/node + date expression.

---

## `query "<question>" [at|before|after <date>]`

Temporally-scoped natural-language graph query.

```python
from semantica.kg.temporal_query_rewriter import TemporalQueryRewriter
from semantica.kg.temporal_normalizer import TemporalNormalizer

normalizer = TemporalNormalizer()
# Normalize natural date expressions: "last month", "Q3 2024", "2025-01-15"
date = normalizer.normalize(date_expr)

rewriter = TemporalQueryRewriter()
# Rewrite query with temporal constraint
rewritten = rewriter.rewrite(
    query=question,
    temporal_constraint={"op": direction, "value": date},  # op: "at"|"before"|"after"
)
```

Then run the rewritten query through `AgentContext.retrieve()` or `ContextGraph.query()`.

Return ranked results with `Valid From`, `Valid Until`, `Active At <date>` columns. Mark nodes that were not yet created at the target time as `[not yet created]`.

---

## `snapshot <date>`

Reconstruct the full graph state as it existed at a specific point in time.

```python
from semantica.context import ContextGraph

graph = ContextGraph(advanced_analytics=True)

# state_at returns a dict snapshot of the graph at that timestamp
snapshot = graph.state_at(timestamp=date)  # ISO string or datetime
```

Output:
```
Graph snapshot at <date>:
  Nodes:       N  (M added since prev snapshot, K removed)
  Edges:       P
  Density:     0.21
  Communities: Q

Active decision categories at <date>:
  | Category | Count | Avg Confidence |

Top 10 nodes (by degree at <date>):
  | Node | Type | Degree |

[Compact Mermaid graph TD — top-10 most connected nodes at that time]
```

---

## `timeline <node_id>`

Show attribute and relationship changes for a node across its full history.

```python
from semantica.context import ContextGraph

graph = ContextGraph()

# Use state_at() at multiple time points to reconstruct history
# Check add_node timestamps and edge addition times from graph data
node_data = graph.find_node(node_id)
```

Output as Markdown timeline:
```
Timeline for "<node_id>" (<type>):

  <timestamp>  CREATED
    Properties: {confidence: 0.71, category: "loan_approval"}
    Source: extraction/pipeline

  <timestamp>  UPDATED
    confidence: 0.71 → 0.91  [source: review]

  <timestamp>  RELATIONSHIP ADDED
    "<node_id>" →[CAUSED]→ "Decision_B"

  <timestamp>  RELATIONSHIP REMOVED
    "<node_id>" →[PRECEDED_BY]→ "Decision_X"  (superseded)

Total lifespan: <duration>
Current state:  <active|superseded>
```

---

## `causal-at <decision_id> <date> [--direction upstream|downstream]`

Trace a causal chain as it existed at a specific point in time.

```python
from semantica.context.causal_analyzer import CausalChainAnalyzer
from semantica.context import AgentContext

ctx = AgentContext(decision_tracking=True)
analyzer = CausalChainAnalyzer(graph_store=ctx.graph_store)

historical_chain = analyzer.trace_at_time(
    event_id=decision_id,
    at_time=date,           # ISO string or datetime
    direction=direction or "upstream",
    max_depth=10,
)
```

Output:
```
Historical causal chain for <decision_id> at <date>:
  Direction: upstream (what caused it?)

  [Mermaid graph TD showing chain as it existed at <date>]

  Decisions present then but not now: [list]
  Decisions added since then: [list]
```

---

## `precedents-at "<scenario>" <date> [--category <cat>]`

Find precedent decisions that existed as of a specific date — useful for auditing what context was available when a decision was made.

```python
from semantica.context import AgentContext

ctx = AgentContext(decision_tracking=True, advanced_analytics=True)

# find_precedents supports as_of parameter for temporal precedent search
precedents = ctx.find_precedents(
    scenario=scenario,
    category=category or None,
    limit=10,
    use_hybrid_search=True,
    include_context=True,
    include_superseded=False,
    as_of=date,  # Only return precedents that existed at this date
)
```

Return: `| Rank | Decision ID | Scenario | Outcome | Confidence | Set Date | Valid Until |`

Note decisions that were superseded before or after the target date.
