interplane.Get Omega
Read in your language

synapse

A component of the AienOS ecosystem.

Brought by drakestapleton

branch main Branches Tags History

synapse / docs / B1_CHANGE_IDENTITY.md

68 lines · 10311 bytes Raw Blame History Source

B1: Change Identity, Admission Witnesses, Obsolescence Markers, Envelope v2

ADR 0003 section 9 step B1 (issue aien-spark/synapse#27). Sections 5.1 ("Identity"), 5.3 (rewrites and markers) and 5.8 (change scope): a ChangeId names one unit of intended work across all its rewrites and retries and is bound to its creating chain; a revision's ChangesetId covers its content only; every admission leaves an immutable AdmissionWitness; obsolescence markers record which revision replaced which.

Code: crates/synapse-core/src/revision.rs (types and codecs), crates/synapse-store/src/revision.rs (ledger, admission, markers), crates/synapse-store/src/{lib,codec}.rs (WAL kinds 7 and 8, replay, checkpoint, compaction), crates/synapse-api/src/lib.rs (submit_revision, record_obsolescence). Tests: crates/synapse-store/tests/b1_change_identity.rs, crates/synapse-api/tests/b1_chained_revisions.rs, unit tests in crates/synapse-core/src/revision.rs. Evidence: evidence/b1-change-identity/.

1. Model and invariants

2. Operations

OperationStoreAPI (F1 chained request, Propose)
Admitadmit_revision(envelope, blobs, AdmissionAuthority, now_ms)submit_revision(req, blobs, now_ms): payload = envelope bytes; scope.join_change = its ChangeId; scope.paths = exactly its mutation paths (so F1 enforces change and path scope); attestation author = request agent; base tree registered or held by the tree store (BaseTreeNotFound)
Markrecord_obsolescence(marker, chain, now_ms)record_obsolescence(req, now_ms): payload = marker bytes; scope.join_change = its ChangeId; signer = request agent
Readget_revision(repo, id), change_status(repo, change_id)through store()

Admission check order: envelope (content rules, attestation names the content, signature), idempotency, path-count limit, join rule, parents (an admitted revision, or a v1 changeset, of the same repository), blobs (provided with digest and size, or already visible). Nothing is written on a refusal. A store still writing v1 JSON records refuses both writes with EnvelopeVersionUnsupported until its migration checkpoint.

3. Canonical binary layout (principle P5)

All integers little-endian; str = u32 len | UTF-8; every length checked against the bytes that remain before allocation; trailing bytes refused. Core decoders refuse with EnvelopeMalformed (EnvelopeVersionUnsupported for a content version other than 2).

The ledger is a pure function of the kind 7 and 8 records in sequence order, so replay, a checkpoint (which keeps the records) and a live store rebuild the same state. Compaction keeps every revision record, every blob a revision references, and every v1 changeset a revision names as parent (no sweep before K1).

4. Acceptance

Acceptance (issue #27)Test
A rewrite keeps ChangeId and gets a new ChangesetIdb1_rewrite_keeps_change_id_and_gets_new_changeset_id
Divergence (two live successors) is detectedb1_divergence_two_live_successors_is_detected
Identical content from two agents of one chain under one ChangeId yields one revision with two attestations and two admission witnessesb1_identical_content_two_agents_one_chain_one_change_is_one_revision_two_attestations_two_witnesses (wal.log and segment stores, through replay and a checkpoint)
A join from a key outside the creating chain without change scope is refusedb1_join_from_key_outside_creating_chain_without_change_scope_is_refused
A prune by a chain that does not dominate the creating chain is refusedb1_prune_by_chain_not_dominating_creating_chain_is_refused
A repeat with the same repository, DID, and IdempotencyKey returns the first WalSeqb1_repeat_same_repo_did_idempotency_key_returns_first_wal_seq (also after replay and a checkpoint)
Every v1 ChangesetId still resolves to its recordb1_every_v1_changeset_id_still_resolves_to_its_record (both v1 fixtures through the migration checkpoint and reopen; a v1 parent outside retention kept by the revision naming it)

Also: b1_revision_records_round_trip_and_malformed_bytes_are_refused_typed, the core unit tests (b1_v2_changeset_id_covers_content_only_not_author_or_time, codec and signature tests), and the API tests with real signed F1 chains (b1_api_*).

Red before green: each acceptance test was run against the B1 commit with one mutation that removes the behaviour it proves (evidence/b1-change-identity/red-green/red.txt), and fails; green.txt holds the passing runs.

5. Limits and deviations