okfsmith logo okfsmith Docs Website EN Open okfsmith
On this page

User guide

Temporal model

Knowledge has a shelf life

A refund policy valid until 2025 is still in your bundle in 2026 — deleting it would destroy history, but surfacing it as current would be wrong. okfsmith's temporal model keeps every version and ranks them by currency:

  1. Validity window — valid_from / valid_until in a concept's frontmatter.
  2. Supersession — supersedes: <older-concept-id> declares a replacement chain.
  3. Trust tier — human-reviewed > machine-confirmed > unverified (as before).
  4. last_verified recency — newest first, but only as a tie-breaker.

Within one currency group the existing BM25 score still picks the best text match; trust and recency only break ties. A human-reviewed concept never loses to an unverified one just because the unverified one is newer — but it does lose to a concept that explicitly supersedes it.

# "What was our refund policy in June 2025?"
okfsmith search ./kb "refund policy" --as-of 2025-06-01

# Include superseded versions (hidden by default, never deleted)
okfsmith search ./kb "refund policy" --include-superseded

Frontmatter fields

All four fields are optional. Malformed values never crash anything — they produce the advisory warnings W016–W020 instead.

---
id: policy/refunds-v2
title: Refund policy v2
valid_from: 2025-07-01        # ISO-8601 date or datetime; naive = UTC
valid_until: 2026-06-30       # date-only covers the whole day through 23:59:59 UTC
supersedes: policy/refunds-v1 # id (or list of ids, max 100) this concept replaces
last_verified: 2026-01-15     # when a human/agent last confirmed this is right
---

Semantics:

  • valid_from / valid_until define the window in which the concept is current. A concept queried before valid_from is future; after valid_until it is expired. Out-of-window concepts are demoted, not hidden — they still appear in results and lists, marked in the Valid column.
  • supersedes links a concept to the older concept(s) it replaces. The newest valid concept at the head of the chain wins; superseded concepts are hidden from search by default (shown last with --include-superseded) and marked superseded→<id> in text output. They are never deleted.
  • last_verified records freshness. Within the same validity + trust group, more recently verified concepts rank first.

Cycle safety: if two concepts supersede each other (validator warning W019), retrieval treats the cycle as unresolved — both concepts stay visible at their own validity instead of hiding each other.

As-of queries

--as-of <ISO-8601 date or datetime> replays retrieval at that instant: validity windows and supersession chains are evaluated then, not now. Useful for audits ("what did we believe in Q2?") and for testing policy changes before they take effect.

okfsmith search ./kb "refund policy" --as-of 2025-06-01 --format json

The same replay works on list, read, and graph — the whole inventory, not just search:

okfsmith list ./kb --as-of 2025-06-01 --format json   # statuses as of then
okfsmith read ./kb policy/refunds --as-of 2025-06-01  # badge as of then
okfsmith graph ./kb --as-of 2025-06-01                # node status as of then

And on validate — the two clock-dependent warnings, W006 (content stale: stale_after has passed) and W020 (last_verified lies in the future), are evaluated at the replay instant instead of now, so an audit can ask "was this bundle stale in June 2025?". Every other validation rule is time-independent, so a replay changes only those two codes:

okfsmith validate ./kb --as-of 2025-06-01 --format json  # W006 / W020 as of then

And on chat — the whole interactive session replays at one instant, so a conversation about the past stays in the past instead of drifting back to now on every question:

okfsmith chat ./kb --as-of 2025-06-01 --no-llm  # answers, /list, /read, /search, /validate, /graph as of then

Each JSON envelope reports the as_of instant evaluated; the HTML viewer labels a replay ("as of …") in its header stats, so a replayed viewer never reads as the present.

The JSON envelope always reports the instant used and how many superseded results were hidden:

{
  "query": "refund policy",
  "as_of": "2025-06-01T00:00:00+00:00",
  "results": [ … ],
  "count": 1,
  "superseded_hidden": 1
}

The dashboard search endpoint offers the same replay over HTTP:

# What did the bundle say about refunds on 2025-06-01?
curl "$DASH/api/v1/search?q=refund%20policy&as_of=2025-06-01" -H "Authorization: Bearer $TOKEN"

# Show superseded concepts too (demoted last, never deleted)
curl "$DASH/api/v1/search?q=refund%20policy&include_superseded=true" -H "Authorization: Bearer $TOKEN"

A blank as_of is ignored; an unparseable one returns 400 bad-as-of. The response envelope always carries the as_of instant the partitioning was evaluated at and superseded_hidden (summed across bundles when the endpoint sweeps bundle_id=all).

The same replay works on the dashboard's three bundle read endpoints — the concepts listing (GET /api/v1/bundles/{id}/concepts), the concept detail (GET /api/v1/bundles/{id}/concepts/{concept_id}), and the graph (GET /api/v1/bundles/{id}/graph): pass ?as_of=2025-06-01 and each temporal_status / superseded_by is evaluated at that instant, with the envelope reporting the instant as as_of. Without it they evaluate at now, as before; a blank as_of is ignored and an unparseable one is the same 400 bad-as-of.

Where temporal status shows up

CommandSurface
searchValid column (expired / future / superseded→<id>); --as-of, --include-superseded; JSON rows carry temporal_status and superseded_by
listValid column (— for concepts with no temporal fields, current / expired / future / superseded otherwise); --as-of replays the column; JSON temporal_status + as_of
readOne-line [temporal: …] badge under the concept when it has temporal data or is superseded; --as-of replays the badge; JSON temporal_status + as_of
graphText report lists non-current concepts; Mermaid labels mark them; JSON nodes carry temporal_status / superseded_by; the HTML viewer strikes non-current nodes through and badges them in the detail panel. --as-of replays all four formats; JSON adds as_of, HTML labels the replay in its header stats.
validateAdvisory warnings W016–W020 (never affect conformance)
chat / MCPThe shared search engine applies the same ranking — temporal behavior is identical everywhere. chat --as-of replays the whole interactive session at one instant: answers, /list, /read, /search (when it carries no --as-of of its own), /validate, and /graph all evaluate at that instant, and the banner labels it ("Replaying as of …"); a per-query /search --as-of still wins over the session instant. The MCP search and list tools carry the same status on each row: a non-current hit/row shows _(superseded by <id>)_, _(expired)_, or _(not yet valid)_, evaluated at the as_of replay instant when one is given, so an agent caller never mistakes history for live knowledge; current rows carry no note. The MCP get tool carries the same status on a note line under the document, also evaluated at the as_of replay instant when one is given, and labels the replay instant on the note (or on a _Replayed as of …._ line when the concept is current at that instant). The MCP traverse tool replays its currency-aware walk — superseded concepts hidden, current-first ordering, temporal notes — at the as_of replay instant too, and the MCP provenance tool evaluates its temporal status line at that instant; both label the replay instant (_Replayed as of …._). The MCP validate tool evaluates the two clock-dependent warnings (W006, W020) at the as_of replay instant too, and labels it (_Validated as of …._). The MCP neighbors tool carries the same status on each outgoing and incoming row — the linked concept's status at the as_of replay instant — and on a note line for the center concept when it is non-current at that instant; it labels the replay instant (_Replayed as of …._). The MCP diff tool carries the same status on each added, removed, and changed row — the concept's status at the as_of replay instant, evaluated against the combined supersession graph of both bundles — and labels the replay instant (_Replayed as of …._); a removed concept in the sync-state mode carries no note, since no frontmatter survives to evaluate.
dashboardGET /api/v1/search accepts ?as_of= (ISO-8601 date or datetime) and ?include_superseded=; the JSON envelope reports the as_of instant used and superseded_hidden, like the CLI, and each hit carries type, trust_tier, temporal_status, superseded_by, and sources (evaluated at the replay instant). The concept detail endpoint (GET /api/v1/bundles/{id}/concepts/{concept_id}) carries the same temporal_status and superseded_by, and both detail views pill a non-current status. The concepts listing endpoint (GET /api/v1/bundles/{id}/concepts) carries the same temporal_status and superseded_by on every item. The graph endpoint (GET /api/v1/bundles/{id}/graph) carries the same temporal_status and superseded_by on every node, and the graph canvas rings a non-current node with a dashed outline (explained in the legend when one is present), so history reads as history without clicking a node open. All three read endpoints accept ?as_of= to replay those statuses at a past/future instant (the dashboard analogue of the CLI's --as-of); each envelope reports the instant as as_of, and without it they evaluate at now. A blank as_of is ignored; an unparseable one is a 400 bad-as-of, like /search. The dashboard chat's /search and /list slash commands show those sources — and the temporal label (Superseded by <id>, Expired, Not yet valid) — on each citation chip's tooltip, so a cited concept's origin file and its status are one hover away

Sync preserves temporal metadata

When sync re-ingests a source whose concepts keep the same ids, their temporal frontmatter (valid_from, valid_until, supersedes, last_verified) is carried over onto the new versions; values already present in the source win. Concepts that are renamed or restructured (new ids) intentionally start fresh — okfsmith never guesses which new concept inherits an old one's history, and it never auto-stamps supersedes (that claim belongs to the source or to you).