# `Agentic.Persistence.Knowledge`

Behaviour for knowledge storage — entries, edges, search, and supersession.

The `:local` fallback uses file-based storage at
`<workspace>/.agentic/knowledge.jsonl`.

The `:recollect` backend delegates to the Recollect knowledge graph.

# `edge`

```elixir
@type edge() :: %{
  id: String.t(),
  source_entry_id: String.t(),
  target_entry_id: String.t(),
  relation: String.t(),
  weight: float()
}
```

# `entry`

```elixir
@type entry() :: %{
  id: String.t(),
  content: String.t(),
  entry_type: String.t(),
  source: String.t(),
  scope_id: String.t() | nil,
  owner_id: String.t() | nil,
  metadata: map(),
  confidence: float(),
  inserted_at: DateTime.t()
}
```

# `create_edge`

```elixir
@callback create_edge(
  from_id :: String.t(),
  to_id :: String.t(),
  relation :: String.t(),
  opts :: keyword()
) :: {:ok, edge()} | {:error, term()}
```

# `create_entry`

```elixir
@callback create_entry(entry :: entry(), opts :: keyword()) ::
  {:ok, entry()} | {:error, term()}
```

# `get_edges`

```elixir
@callback get_edges(entry_id :: String.t(), direction :: :from | :to, opts :: keyword()) ::
  {:ok, [edge()]} | {:error, term()}
```

# `get_entry`

```elixir
@callback get_entry(entry_id :: String.t(), opts :: keyword()) ::
  {:ok, entry()} | {:error, :not_found}
```

# `recent`

```elixir
@callback recent(scope_id :: String.t(), opts :: keyword()) ::
  {:ok, [entry()]} | {:error, term()}
```

# `search`

```elixir
@callback search(query :: String.t(), opts :: keyword()) ::
  {:ok, [entry()]} | {:error, term()}
```

# `supersede`

```elixir
@callback supersede(
  scope_id :: String.t(),
  entity :: String.t(),
  relation :: String.t(),
  new_value :: String.t()
) :: {:ok, [entry()]} | {:error, term()}
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
