amduat-api/tier1/asl-federation-replay-1.md

122 lines
2.9 KiB
Markdown
Raw Normal View History

# ASL/FEDERATION-REPLAY/1 -- Cross-Node Deterministic Replay
Status: Draft
Owner: Architecture
Version: 0.1.0
SoT: No
Last Updated: 2025-01-17
Tags: [federation, replay, determinism, tgk, pel]
**Document ID:** `ASL/FEDERATION-REPLAY/1`
**Layer:** L2 -- Federation replay semantics (no transport)
**Depends on (normative):**
* `ASL/FEDERATION/1`
* `ASL/LOG/1`
* `ASL/1-CORE-INDEX`
* `TGK/1`
**Informative references:**
* `ASL/SYSTEM/1` -- unified system view
* `ENC-ASL-CORE-INDEX` -- domain metadata
---
## 0. Conventions
The key words **MUST**, **MUST NOT**, **REQUIRED**, **SHOULD**, and **MAY** are to be interpreted as in RFC 2119.
ASL/FEDERATION-REPLAY/1 defines **deterministic replay rules** for federated propagation. It does not define network protocols or encodings.
---
## 1. Purpose
This document defines how artifacts, PERs, and TGK edges are propagated and replayed across federation nodes while preserving deterministic reconstruction.
---
## 2. Core Inputs
* **ArtifactKey**: canonical identifier for artifacts and PERs
* **SnapshotID**: snapshot boundary for replay
* **logseq**: append-only ordering within a domain
* **Canonical Edge Key**: TGK edge identity
---
## 3. Propagation Rules
### 3.1 Artifacts and PERs
* Artifacts and PERs are propagated with their `ArtifactKey` and `logseq`.
* Only artifacts visible under a published snapshot MAY be propagated.
* Duplicate ArtifactKeys MUST be de-duplicated by identity.
### 3.2 TGK Edges
* TGK edges are propagated with their canonical edge identity and `logseq`.
* Edge propagation MUST preserve the same snapshot/log visibility constraints as artifacts.
---
## 4. Deterministic Replay Ordering
Replay order MUST be deterministic across nodes:
1. Sort by `logseq` ascending
2. Tie-break by canonical identity (ArtifactKey or Canonical Edge Key)
This ordering MUST be applied identically by all receivers.
---
## 5. Snapshot Bounds
* Replay MUST be bounded by `{SnapshotID, LogPrefix}`.
* Records with `logseq` greater than the replay prefix MUST be ignored.
---
## 6. Conflict Handling
1. **ArtifactKey collision**
* If bytes match existing artifact: discard duplicate.
* If bytes differ: reject and flag conflict.
2. **TGK edge conflicts**
* Multiple edges with the same canonical identity are resolved by log order and tombstone rules.
3. **PER conflicts**
* PERs with identical inputs and program identity but divergent outputs MUST be rejected.
---
## 7. Provenance and Audit
Receivers SHOULD maintain:
* Last applied `logseq` per peer
* Snapshot provenance tables for applied records
This supports deterministic audit and replay verification.
---
## 8. Non-Goals
* Transport protocol selection
* Streaming formats
* Compression or batching
---
## 9. Summary
ASL/FEDERATION-REPLAY/1 defines a deterministic replay ordering and conflict rules to ensure federation is reproducible across nodes and snapshots.