Skip to content

History reference (spoke-history) ​

spoke-history is the optional capability for exact-revision replay of stored entities and explicit pruning of retained checkpoints. It covers KnowledgeEntry and Relation data; checkpoint storage and reconstruction stay provider-owned.

Capability ​

AspectContract
Capability stringspoke-history — an optional member of HostCapabilityManifest.capabilities
Manifest declarationThe host serves the revision-snapshot and history operation contract
DependencyNo co-capability; spoke-baseline and spoke-knowledge neither imply nor replace it
NegotiationBoth Connect peers advertise it for the string to enter negotiated_capabilities; dispatch requires exact membership in that negotiated set
Connect surfaceGates history.revisions.get and history.revisions.prune

capabilities is an open string array with unique members, so declaring spoke-history is additive to the existing capability vocabulary.

Exact spoke-history membership admits the core row. A request whose scope.cognition declares a requirement additionally needs spoke-cognition in the negotiated set: the responder refuses capability_missing before probing the history port, so spoke-history alone does not admit a cognition-bearing request.

Operations ​

opRequestSuccess valueIdempotency
history.revisions.getHistoryRevisionsGetRequest — entity_kind, entity_id, revision; optional scope, extensionsRevisionSnapshotRead-only; no idempotency key
history.revisions.pruneHistoryRevisionsPruneRequest — entity_kind, entity_id, keep, idempotency_key; optional scope, extensionsHistoryPruneResult with deleted and floor_revisionRequired

Both operations travel the existing opaque Connect payload and response envelopes. idempotency_key contains 1–128 Unicode code points; the length is counted in code points, not UTF-16 code units or UTF-8 bytes.

RevisionSnapshot ​

A closed object with these required fields:

FieldTypeContract
schema_versionshared SchemaVersionVersion of the RevisionSnapshot wire schema
entity_kindstringEntity-kind selector; core values are knowledge_entry and relation
entity_idstringOpaque stable entity id; equals snapshot.entry_id for a knowledge entry and snapshot.relation_id for a relation
revisioninteger ≥ 0Revision represented by the snapshot; equals the selected entity snapshot's own revision
snapshotoneOf: KnowledgeEntry | RelationThe stored entity as it stood at revision, with its stored fields intact
extensionsshared ExtensionMapProduct-namespace extensions; unknown namespaces and keys round-trip unchanged

The snapshot variant agrees with entity_kind. A knowledge entry carries its stored body, modules, owner, disclosure, source_anchor, status, and extensions when present; a relation carries its existing relation envelope. Two providers returning the same snapshot at the same revision produce identical bytes under RFC 8785 canonical JSON. Stored created_at and updated_at replay their stored wire strings verbatim — separator case, fractional-second digits, and offset spelling unchanged.

HistoryPruneResult ​

FieldTypeContract
deletedinteger ≥ 0Number of checkpoints deleted by the call; excludes the live row and derived revisions
floor_revisioninteger ≥ 0 | nullCurrent retained floor: the newest deleted checkpoint revision plus one, or null when nothing was deleted

Retained floor ​

A checkpoint is a retained preimage used to reconstruct historical revisions. The live row is not a checkpoint and never consumes keep.

For one (scope, entity_kind, entity_id) target, prune_history(..., keep) retains the newest keep checkpoints and deletes every older checkpoint:

  • With checkpoints {1, 3, 5} and keep = 2, the retained set is {3, 5} and the deleted set is {1}, so deleted = 1 and floor_revision = 2.
  • A replay of revision 1 is below the floor and refuses HISTORY_TRUNCATED with details.floor_revision = 2.
  • A replay of revision 2 is at the floor and is answered from retained checkpoint 3.
  • A prune that deletes nothing returns { "deleted": 0, "floor_revision": null }.

Replay answers a revision at or above the floor from the nearest retained checkpoint at or above the requested revision. A revision at or above the floor that cannot be reconstructed because of an implementation-declared retention gap refuses HISTORY_NOT_RETAINED.

HistoryPort ​

HistoryPort is standalone and composes separately from KnowledgeEntryPort and RelationPort. The asynchronous signatures are:

text
get_history_snapshot(principal, scope, entity_kind, entity_id, revision)
  -> SpokeResult<RevisionSnapshot>

prune_history(principal, scope, entity_kind, entity_id, keep)
  -> SpokeResult<HistoryPruneResult>

Every method takes the authenticated Principal as its first admission-context parameter and the required Scope second, so entity read and write authorization bind to the caller rather than to payload-asserted identity. TypeScript uses camelCase names and Promise<SpokeResult<T>>; Rust uses #[async_trait] async fn with the snake_case names above. Expected outcomes are returned as SpokeResult, not thrown.

The Connect serving face is RemoteHistoryService over a provider HistoryPort via HistoryPortService, mirroring RemoteMemoryService / MemoryPortService. The service owns peer admission, effective-scope resolution, and prune deduplication.

Refusal vocabulary ​

CodeConditionRequired details
HISTORY_TRUNCATEDThe requested revision is below the current retained floor and its checkpoint history was discarded{ "floor_revision": integer ≥ 0 }
HISTORY_ENTITY_UNSUPPORTEDConnect admitted the operation but the host does not serve the requested entity_kind{ "entity_kind": string } with the exact requested kind
HISTORY_NOT_RETAINEDThe requested revision is at or above the floor but cannot be reconstructed because of an implementation-declared retention gap{ "retention_reason": string } — provider-supplied, human-readable; the stable code remains authoritative
capability_missingspoke-history is absent from the negotiated set, or the request declares a scope.cognition requirement while spoke-cognition is absent from it; either deny precedes the history face probeNone; the refusal precedes the handler with no side effects
op_unsupportedspoke-history is negotiated but the host exposes no history serving face (HistoryPort service)None; the refusal precedes the handler with no side effects
invalid_inputThe request's negotiated scope.cognition requirement is unsupported or invalid — an unknown predicate, an unimplemented view/dimension/metric, or an unavailable recorded_at view; refused at the dispatch boundary with this lowercase code, distinct from the serving decoder's INVALID_INPUT{ "reason": "unsupported_cognition_requirement", "field": string }; field is the carrier-relative path, for example scope.cognition.view
INVALID_INPUTMalformed request; an absent idempotency_key on prune; a revision or keep value outside the receiving runtime's exact-integer range{ "op": string }; the decoder diagnostic is carried in message and callers branch on the code
NOT_FOUNDThe entity is missing or non-disclosable, or the request scope differs from the peer's admitted scope on history.revisions.getNone beyond the shared envelope
Entity authorization outcomeA prune caller lacks the selected entity's write permission, or the request scope differs from the admitted scope on pruneThe entity's existing write-authorization refusal
STORED_REVISION_STALEA conditional entity put names an expected_base_revision that does not equal the current row revision; history floor state plays no partThe entity's existing stale-revision details, for example { "expectedBaseRevision": 1, "storeRevision": 5 }
IDEMPOTENCY_CONFLICTA prune retry reuses the same key with a different payload digestNone
RECEIPT_EXPIREDA prune retry replays a key whose recorded outcome was evictedNone
INTERNAL_ERRORhistory.revisions.get: a zero serve budget refuses before the history service is invoked; a non-zero budget that expires after invocation answers the plain serve timeout (details.kind = "timeout"); a thrown or failed service call — the service panics, drops its result channel, or throws — answers the plain internal error with no details; a malformed or wrong-target provider snapshot answers INTERNAL_ERROR with details.kind = "transport". A rejection the service itself returns (for example HISTORY_TRUNCATED) passes through unchanged. The responder never generates OUTCOME_UNCERTAIN for a read.{ "kind": "timeout" } on the budget paths; absent on a thrown or failed service call; { "kind": "transport" } on a malformed or wrong-target snapshot
INTERNAL_ERRORhistory.revisions.prune: a zero serve budget refuses before the history service is invoked; the provider was never called{ "kind": "timeout" }
OUTCOME_UNCERTAINhistory.revisions.prune: a non-zero serve budget expires after invocation, or a transport-generated post-invocation failure — the detached invoke panics, drops its result channel, or throws; the provider outcome is unknown. A rejection the service itself returns passes through unchanged.{ "retry_class": "uncertain", "kind": "timeout" | "panic" }

Only the two registered ops (history.revisions.get and history.revisions.prune) reach the history face. Any other history.* op is refused at the capability gate — op_unsupported, or capability_missing when the op maps to a capability — before the face probe, so it never reaches invocation.

HISTORY_TRUNCATED, HISTORY_ENTITY_UNSUPPORTED, and HISTORY_NOT_RETAINED are new SpokeRejectCode members; the remaining codes keep their established meanings.

Usage constraints ​

  • Replay is entity data. A snapshot returns the stored entity exactly as it stood at revision; replay does not re-derive cognition or other derived state. A stored modules.cognition value travels as entity data, and derived views such as MindState keep their own owner.
  • Byte presence survives. Present-and-empty stored members, including body.tags: [], body.state: {}, modules: {}, body.attributes: [], and map-shaped body.computable, survive replay and RFC 8785 canonicalization with their member names and empty values byte-identical.
  • Entity kinds are open. Core values are knowledge_entry and relation. A provider serving an additional kind declares the core shape (KnowledgeEntry or Relation) under which it encodes the stored entity and uses that snapshot branch consistently; otherwise it answers HISTORY_ENTITY_UNSUPPORTED. An unknown kind is never routed to a core entity port.
  • Pruning is explicit. history.revisions.prune is the only path that deletes checkpoints; no write path prunes implicitly. keep counts retained checkpoints and excludes the live row.
  • Prune uses entity write permission. Pruning requires exactly the same permission as a put to the selected entity in the same scope. Reads follow the selected entity's read and disclosure rules. There is no separate history_admin grant and no history-specific authorization code.
  • Idempotency is connect-owned. The service records {payload_digest, outcome} under (effective_scope, requester_principal_id, op, idempotency_key), where payload_digest is SHA-256 over RFC 8785 canonical JSON of the request payload. Same-key, same-digest replay returns the recorded outcome without re-executing the port call; a recorded response-validation failure replays as that error; a different digest answers IDEMPOTENCY_CONFLICT; an evicted record answers RECEIPT_EXPIRED and never re-executes. Dedup records outlive a Connect session, and a tombstone from an evicted record is retained for the store's lifetime.
  • OCC is unchanged. A conditional entity put compares expected_base_revision against the current row revision; history adds no parallel write-conflict refusal, and neither floor state nor retained history admits or refuses a write.
  • Integer range is exact. revision and keep have u64 semantics with no schema maximum. A runtime that cannot represent a received value exactly refuses the request with INVALID_INPUT at decode and never rounds, truncates, or coerces it.
  • Scope is admitted, not asserted. The request scope is optional; when present it equals the admitted scope. A mismatch answers NOT_FOUND for get and the selected entity's write-authorization denial for prune, without invoking the port.
  • Success values validate at both decode boundaries. The serving face validates provider output before emitting success and each RemoteAdapter validates the response before returning Ok; a malformed success value produces a transport decode error, never Ok.