Skip to content
Alpha: see what works today →
Menu

For tools: runtime/sync.feature

Syncs

The scenario the examples run

What a writer writes when files arrive from another writer of the same pod. Writers follow git: a writer has no id, its last snapshot is its own state outside the pod (N14), and a sync's snapshot is a merge.

Each pod starts empty, at https://pod.example/, with one person as its subject (scripted-input/people.ttl). Dev's pod gets a second writer before Dev enters anything; the first writer takes the entry "later", the second the entry "pairs", and each receives the other's files. Cleo's pod gets a second writer once she has claimed her hospital profile; both writers import her first export, the first writer also takes her entry, and the second receives the first's files. Ada's pod gets a second writer before anything arrives; both writers import her first export, the second receives the first's files, and then imports the export that changes her peanut allergy.

6 rules, 8 examples: 8 pass, 0 fail, 0 not run

S1. A sync is written whenever the writer holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot

Ruled by How everything in a pod is named, row sync; What a pod costs as it grows, row sync as union, with the no-hash test; Where a host keeps a pod's files, row a sync

A writer receiving another writer's files writes each it lacks, in a folder the layout gives by solid:instanceContainer but the views', the archives' and the requirements', in W1's order: the stored documents first, then the other files of the set, then the act files, each after those holding its snapshot's parents, and its sync last. Whether it writes a sync, and which acts the sync names (S2), depends on what the writer holds, never on what this receiving wrote: it writes one whenever it holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot, any act other than a sync on a writer's first. So a receiving that stops partway and is tried again writes the same sync, naming the same acts. The sync is a cascade:SyncFromAnotherWriter and a prov:Activity, a new random UUID (N7), with its prov:startedAtTime, in a file of the folder the layout gives cascade:SyncFromAnotherWriter. The files that arrived are the transport's, not the sync's: the step wrote only the sync's file.

A file is the same file wherever a host keeps it (X1), so which files a writer lacks is decided by path, and the files arrive as files whether the other writer kept them at their paths or in archives. A host that keeps files in archives writes the files that arrived as W1 writes a step's: the stored documents at their paths, then the rest as archives. A host that keeps archives may instead take whole archives the writer lacks, and keep them as they are at their names after the stored documents it lacks, since a reader takes every archive and a file held twice holds the same bytes in both. What a pod requires of a runtime follows how its host keeps its files, not the other writer's: the receiver takes no requirement's file (O4), and writes the one each kept file needs before it, first of all (W1).

Why six kinds of act, and a snapshot per act. Every file an act writes is credited to it, which is what the audit trail and the snapshot rest on. A connect writes what a server reports, a migration writes a release's retractions, a run writes matcher judgments and assertions; folding them into an import would pretend a connect with no pull, or a migration by a writer that never imports, happened inside one. So each is an act with a random id, a start, an agent and a snapshot, and the snapshot exists because per-file integrity says nothing about the set being whole. The snapshot is a chain, its previous snapshot and this act's additions with an order-free hash of the set, because a list of every file per act grows with the square of the pod: 170 to 490 GB over ten years and 12,300 acts (5,000 and 7,300 pulls; the 70 to 200 GB of 5,000 acts scaled by 2.46) against a pod of 36 to 38 GB, where git's tree with this layout is 2.5 to 5 GB over those acts (the 1 to 2 GB of 5,000 acts scaled by 2.46) and the chain 60 to 115 MB (computed from a stated ten-year pod, #206); the set only grows, so a chain loses nothing, and "in sync" is one comparison of two hashes. A sync is an act because "when did this writer first see that import" is history nothing else records, and the matcher run the union calls for needs a cause to name; it is written only when the writer holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot, because a background transport syncs many times a day and moves nothing in nearly all of them, because what the writer holds survives a transfer that stops partway where a list of what one transfer moved does not, and because an act that counted syncs would fire on its own arrival at the other writer. That test says whether anything an act wrote has reached the writer unmerged, at the cost of a walk of the snapshots it holds, and the files that change in place are outside the set, or every view rebuild would change it. Union needs no merge step of its own: two writers that imported one record wrote one version file by name, and two that ran one rule on one pair wrote one matcher judgment, so the only things a union leaves are two heads of one record, which the ladder in currency.md ranks, and pairs no matcher saw together, which the run the sync triggers takes, bound to the records the sync brought (republishing-sources.md).

How everything in a pod is named: the whole Why, the alternatives that lost and what would change our mind.

1 example: 1 pass, 0 fail, 0 not run

passa sync that brings an entry writes one file, its act's
Example: a sync that brings an entry writes one file, its act's
  Given a new pod for Dev on 2026-04-01 at 09:00
  And a second writer of the pod
  And Dev enters "later" on 2026-04-04 at 09:00
  When the second writer receives the files of the first writer on 2026-04-05 at 09:00
  Then "sync" wrote 1 file

S2. A sync names each act it is written for, and the runtime that performed it

Ruled by How everything in a pod is named, row sync

It is prov:wasInformedBy each act, other than a sync, whose snapshot is no ancestor of the writer's last snapshot: an act is held once its file, which holds its snapshot, is. It says prov:wasAssociatedWith the runtime, as every act does (N7). The matcher run it causes takes the records all of whose first revisions those acts generated (M1).

Why six kinds of act, and a snapshot per act. Every file an act writes is credited to it, which is what the audit trail and the snapshot rest on. A connect writes what a server reports, a migration writes a release's retractions, a run writes matcher judgments and assertions; folding them into an import would pretend a connect with no pull, or a migration by a writer that never imports, happened inside one. So each is an act with a random id, a start, an agent and a snapshot, and the snapshot exists because per-file integrity says nothing about the set being whole. The snapshot is a chain, its previous snapshot and this act's additions with an order-free hash of the set, because a list of every file per act grows with the square of the pod: 170 to 490 GB over ten years and 12,300 acts (5,000 and 7,300 pulls; the 70 to 200 GB of 5,000 acts scaled by 2.46) against a pod of 36 to 38 GB, where git's tree with this layout is 2.5 to 5 GB over those acts (the 1 to 2 GB of 5,000 acts scaled by 2.46) and the chain 60 to 115 MB (computed from a stated ten-year pod, #206); the set only grows, so a chain loses nothing, and "in sync" is one comparison of two hashes. A sync is an act because "when did this writer first see that import" is history nothing else records, and the matcher run the union calls for needs a cause to name; it is written only when the writer holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot, because a background transport syncs many times a day and moves nothing in nearly all of them, because what the writer holds survives a transfer that stops partway where a list of what one transfer moved does not, and because an act that counted syncs would fire on its own arrival at the other writer. That test says whether anything an act wrote has reached the writer unmerged, at the cost of a walk of the snapshots it holds, and the files that change in place are outside the set, or every view rebuild would change it. Union needs no merge step of its own: two writers that imported one record wrote one version file by name, and two that ran one rule on one pair wrote one matcher judgment, so the only things a union leaves are two heads of one record, which the ladder in currency.md ranks, and pairs no matcher saw together, which the run the sync triggers takes, bound to the records the sync brought (republishing-sources.md).

How everything in a pod is named: the whole Why, the alternatives that lost and what would change our mind.

2 examples: 2 pass, 0 fail, 0 not run

passa sync is named by a new random UUID and names the entry session that arrived
Example: a sync is named by a new random UUID and names the entry session that arrived
  Given a new pod for Dev on 2026-04-01 at 09:00
  And a second writer of the pod
  And Dev enters "later" on 2026-04-04 at 09:00
  When the second writer receives the files of the first writer on 2026-04-05 at 09:00
  When the query is:
    """
    SELECT ?random ?informedBy ?runtime WHERE {
      GRAPH <urn:cascade:steps> { <urn:cascade:step:sync> prov:generated ?file }
      GRAPH ?file { ?sync a cascade:SyncFromAnotherWriter, prov:Activity ; prov:startedAtTime [] ;
                      prov:wasInformedBy ?informedBy ; prov:wasAssociatedWith ?runtime }
      BIND (REGEX(STR(?sync), "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$") AS ?random)
    }
    """
  Then it answers:
    | random | informedBy                                      | runtime     |
    | true   | <urn:uuid:92c5264b-3382-4bf8-aa8a-2458a549e98c> | the runtime |
passafter both writers imported one export, the sync's run takes only the entry the other writer made
Example: after both writers imported one export, the sync's run takes only the entry the other writer made
  Each record of the export has two first revisions, one from each writer's import. The sync names the first
  writer's import and its entry session, but only the entry's records have no first revision from an act the sync
  does not name, so the run compares those alone, each with every record the second writer holds.

  Given a new pod for Cleo on 2026-03-01 at 09:00
  And Cleo files the judgment "about-p" on 2026-03-01 at 09:05
  And a second writer of the pod
  And the export "first-export" is imported on 2026-03-02 at 10:00
  And the steps that follow are the second writer's
  And the export "first-export" is imported on 2026-03-02 at 10:00 (second-import)
  And the steps that follow are the first writer's
  And Cleo enters "entry" on 2026-03-03 at 08:00
  And the second writer receives the files of the first writer on 2026-03-03 at 09:00
  When the matcher runs on the records of that step on 2026-03-03 at 09:05
  Then that step wrote these matcher judgments:
    | justification    | members                                                                                                         |
    | same code        | allergy RxNorm 10180 from sulfa, allergy RxNorm 10180 "Gantanol"                                                |
    | same code        | allergy RxNorm 1191 "Aspirin", allergy RxNorm 1191 "Bayer aspirin"                                              |
    | same code        | allergy RxNorm 1191 "Bayer aspirin", allergy RxNorm 1191 "Ecotrin"                                              |
    | same code        | allergy RxNorm 7980 "Penicillin G", allergy RxNorm 7980 "Bicillin"                                              |
    | same code        | allergy RxNorm 2670 from codeine-1, allergy RxNorm 2670 from codeine-2, allergy RxNorm 2670 "Codeine phosphate" |

S3. A sync's snapshot merges every head the writer holds

Ruled by How everything in a pod is named, rows snapshot, sync

Its cascade:firstParentSnapshot is the writer's last snapshot, and its cascade:mergedParentSnapshot values are every head the writer holds once the files that arrived are written, each snapshot it holds that no snapshot it holds names as a parent, but the first parent, as git merges; on a writer's first, it has no first parent and merges every head it holds (N14). Its cascade:setHash is N14's, over the set the writer holds once the files that arrived are written, and it names no cascade:fileAddedToSet: the sync wrote no file of the set, and the files that arrived are named by the snapshots of the acts that wrote them.

Why six kinds of act, and a snapshot per act. Every file an act writes is credited to it, which is what the audit trail and the snapshot rest on. A connect writes what a server reports, a migration writes a release's retractions, a run writes matcher judgments and assertions; folding them into an import would pretend a connect with no pull, or a migration by a writer that never imports, happened inside one. So each is an act with a random id, a start, an agent and a snapshot, and the snapshot exists because per-file integrity says nothing about the set being whole. The snapshot is a chain, its previous snapshot and this act's additions with an order-free hash of the set, because a list of every file per act grows with the square of the pod: 170 to 490 GB over ten years and 12,300 acts (5,000 and 7,300 pulls; the 70 to 200 GB of 5,000 acts scaled by 2.46) against a pod of 36 to 38 GB, where git's tree with this layout is 2.5 to 5 GB over those acts (the 1 to 2 GB of 5,000 acts scaled by 2.46) and the chain 60 to 115 MB (computed from a stated ten-year pod, #206); the set only grows, so a chain loses nothing, and "in sync" is one comparison of two hashes. A sync is an act because "when did this writer first see that import" is history nothing else records, and the matcher run the union calls for needs a cause to name; it is written only when the writer holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot, because a background transport syncs many times a day and moves nothing in nearly all of them, because what the writer holds survives a transfer that stops partway where a list of what one transfer moved does not, and because an act that counted syncs would fire on its own arrival at the other writer. That test says whether anything an act wrote has reached the writer unmerged, at the cost of a walk of the snapshots it holds, and the files that change in place are outside the set, or every view rebuild would change it. Union needs no merge step of its own: two writers that imported one record wrote one version file by name, and two that ran one rule on one pair wrote one matcher judgment, so the only things a union leaves are two heads of one record, which the ladder in currency.md ranks, and pairs no matcher saw together, which the run the sync triggers takes, bound to the records the sync brought (republishing-sources.md).

How everything in a pod is named: the whole Why, the alternatives that lost and what would change our mind.

1 example: 1 pass, 0 fail, 0 not run

passeach writer's sync names its own last snapshot first and merges the other's head
Example: each writer's sync names its own last snapshot first and merges the other's head
  The second writer's sync merges the first writer's entry. The first writer's merges the second writer's sync,
  which names the second writer's entry as a parent, so that entry is no head.

  Given a new pod for Dev on 2026-04-01 at 09:00
  And a second writer of the pod
  And Dev enters "later" on 2026-04-04 at 09:00
  And the steps that follow are the second writer's
  And Dev enters "pairs" on 2026-04-04 at 10:00
  And the second writer receives the files of the first writer on 2026-04-05 at 09:00
  When the first writer receives the files of the second writer on 2026-04-05 at 10:00 (sync-back)
  When the query is:
    """
    SELECT ?step ?firstParentStep ?mergedParentStep (COUNT(?added) AS ?filesAdded) WHERE {
      GRAPH <urn:cascade:steps> { ?step prov:generated ?file }
      GRAPH ?file { ?snapshot a cascade:Snapshot ; prov:wasGeneratedBy ?sync . ?sync a cascade:SyncFromAnotherWriter }
      OPTIONAL {
        GRAPH ?file { ?snapshot cascade:firstParentSnapshot ?first }
        GRAPH <urn:cascade:steps> { ?firstParentStep prov:generated ?firstFile }
        GRAPH ?firstFile { ?first a cascade:Snapshot }
      }
      OPTIONAL {
        GRAPH ?file { ?snapshot cascade:mergedParentSnapshot ?merged }
        GRAPH <urn:cascade:steps> { ?mergedParentStep prov:generated ?mergedFile }
        GRAPH ?mergedFile { ?merged a cascade:Snapshot }
      }
      OPTIONAL { GRAPH ?file { ?snapshot cascade:fileAddedToSet ?added } }
    }
    GROUP BY ?step ?firstParentStep ?mergedParentStep
    """
  Then it answers:
    | step                         | firstParentStep            | mergedParentStep           | filesAdded |
    | <urn:cascade:step:sync>      | <urn:cascade:step:pairs>   | <urn:cascade:step:later>   | 0          |
    | <urn:cascade:step:sync-back> | <urn:cascade:step:later>   | <urn:cascade:step:sync>    | 0          |

S4. A writer given only syncs writes nothing, and takes the one head it then holds as its last snapshot

Ruled by How everything in a pod is named, row sync

No sync names a sync, so syncs arriving alone give the writer no act to name: two writers that sync back and forth settle. The files that arrived are written all the same. When the writer then holds one head, and it is not the writer's last snapshot, that head descends from it and becomes its last snapshot, as git fast-forwards: the writer's next act's first parent is the sync that arrived, and no head is left behind.

Why six kinds of act, and a snapshot per act. Every file an act writes is credited to it, which is what the audit trail and the snapshot rest on. A connect writes what a server reports, a migration writes a release's retractions, a run writes matcher judgments and assertions; folding them into an import would pretend a connect with no pull, or a migration by a writer that never imports, happened inside one. So each is an act with a random id, a start, an agent and a snapshot, and the snapshot exists because per-file integrity says nothing about the set being whole. The snapshot is a chain, its previous snapshot and this act's additions with an order-free hash of the set, because a list of every file per act grows with the square of the pod: 170 to 490 GB over ten years and 12,300 acts (5,000 and 7,300 pulls; the 70 to 200 GB of 5,000 acts scaled by 2.46) against a pod of 36 to 38 GB, where git's tree with this layout is 2.5 to 5 GB over those acts (the 1 to 2 GB of 5,000 acts scaled by 2.46) and the chain 60 to 115 MB (computed from a stated ten-year pod, #206); the set only grows, so a chain loses nothing, and "in sync" is one comparison of two hashes. A sync is an act because "when did this writer first see that import" is history nothing else records, and the matcher run the union calls for needs a cause to name; it is written only when the writer holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot, because a background transport syncs many times a day and moves nothing in nearly all of them, because what the writer holds survives a transfer that stops partway where a list of what one transfer moved does not, and because an act that counted syncs would fire on its own arrival at the other writer. That test says whether anything an act wrote has reached the writer unmerged, at the cost of a walk of the snapshots it holds, and the files that change in place are outside the set, or every view rebuild would change it. Union needs no merge step of its own: two writers that imported one record wrote one version file by name, and two that ran one rule on one pair wrote one matcher judgment, so the only things a union leaves are two heads of one record, which the ladder in currency.md ranks, and pairs no matcher saw together, which the run the sync triggers takes, bound to the records the sync brought (republishing-sources.md).

How everything in a pod is named: the whole Why, the alternatives that lost and what would change our mind.

2 examples: 2 pass, 0 fail, 0 not run

passthe second writer, given the first writer's sync alone, writes nothing
Example: the second writer, given the first writer's sync alone, writes nothing
  Given a new pod for Dev on 2026-04-01 at 09:00
  And a second writer of the pod
  And Dev enters "later" on 2026-04-04 at 09:00
  And the steps that follow are the second writer's
  And Dev enters "pairs" on 2026-04-04 at 10:00
  And the second writer receives the files of the first writer on 2026-04-05 at 09:00
  And the first writer receives the files of the second writer on 2026-04-05 at 10:00 (sync-back)
  When the second writer receives the files of the first writer on 2026-04-05 at 11:00 (settle)
  Then "settle" wrote no file
passthe second writer's next act follows the first writer's sync
Example: the second writer's next act follows the first writer's sync
  Given a new pod for Dev on 2026-04-01 at 09:00
  And a second writer of the pod
  And Dev enters "later" on 2026-04-04 at 09:00
  And the steps that follow are the second writer's
  And Dev enters "pairs" on 2026-04-04 at 10:00
  And the second writer receives the files of the first writer on 2026-04-05 at 09:00
  And the first writer receives the files of the second writer on 2026-04-05 at 10:00 (sync-back)
  And the second writer receives the files of the first writer on 2026-04-05 at 11:00 (settle)
  When the matcher runs on the records of "pairs" on 2026-04-05 at 12:00
  When the query is:
    """
    SELECT ?firstParentStep (COUNT(?merged) AS ?mergedParents) WHERE {
      GRAPH <urn:cascade:steps> { <urn:cascade:step:matcher> prov:generated ?file }
      GRAPH ?file { ?snapshot a cascade:Snapshot ; cascade:firstParentSnapshot ?parent }
      GRAPH <urn:cascade:steps> { ?firstParentStep prov:generated ?parentFile }
      GRAPH ?parentFile { ?parent a cascade:Snapshot }
      OPTIONAL { GRAPH ?file { ?snapshot cascade:mergedParentSnapshot ?merged } }
    }
    GROUP BY ?firstParentStep
    """
  Then it answers:
    | firstParentStep              | mergedParents |
    | <urn:cascade:step:sync-back> | 0             |

S5. Two writers hold one set when the set hashes of what each holds agree, whatever order the files arrived in

Ruled by How everything in a pod is named, rows snapshot, sync

The set hash is order-free, so two writers that each received the other's files carry one set hash on those syncs' snapshots, though neither received them in the order the other did.

Why six kinds of act, and a snapshot per act. Every file an act writes is credited to it, which is what the audit trail and the snapshot rest on. A connect writes what a server reports, a migration writes a release's retractions, a run writes matcher judgments and assertions; folding them into an import would pretend a connect with no pull, or a migration by a writer that never imports, happened inside one. So each is an act with a random id, a start, an agent and a snapshot, and the snapshot exists because per-file integrity says nothing about the set being whole. The snapshot is a chain, its previous snapshot and this act's additions with an order-free hash of the set, because a list of every file per act grows with the square of the pod: 170 to 490 GB over ten years and 12,300 acts (5,000 and 7,300 pulls; the 70 to 200 GB of 5,000 acts scaled by 2.46) against a pod of 36 to 38 GB, where git's tree with this layout is 2.5 to 5 GB over those acts (the 1 to 2 GB of 5,000 acts scaled by 2.46) and the chain 60 to 115 MB (computed from a stated ten-year pod, #206); the set only grows, so a chain loses nothing, and "in sync" is one comparison of two hashes. A sync is an act because "when did this writer first see that import" is history nothing else records, and the matcher run the union calls for needs a cause to name; it is written only when the writer holds an act, other than a sync, whose snapshot is no ancestor of its last snapshot, because a background transport syncs many times a day and moves nothing in nearly all of them, because what the writer holds survives a transfer that stops partway where a list of what one transfer moved does not, and because an act that counted syncs would fire on its own arrival at the other writer. That test says whether anything an act wrote has reached the writer unmerged, at the cost of a walk of the snapshots it holds, and the files that change in place are outside the set, or every view rebuild would change it. Union needs no merge step of its own: two writers that imported one record wrote one version file by name, and two that ran one rule on one pair wrote one matcher judgment, so the only things a union leaves are two heads of one record, which the ladder in currency.md ranks, and pairs no matcher saw together, which the run the sync triggers takes, bound to the records the sync brought (republishing-sources.md).

How everything in a pod is named: the whole Why, the alternatives that lost and what would change our mind.

1 example: 1 pass, 0 fail, 0 not run

passthe two writers' syncs carry one set hash
Example: the two writers' syncs carry one set hash
  Given a new pod for Dev on 2026-04-01 at 09:00
  And a second writer of the pod
  And Dev enters "later" on 2026-04-04 at 09:00
  And the steps that follow are the second writer's
  And Dev enters "pairs" on 2026-04-04 at 10:00
  And the second writer receives the files of the first writer on 2026-04-05 at 09:00
  And the first writer receives the files of the second writer on 2026-04-05 at 10:00 (sync-back)
  When the second writer receives the files of the first writer on 2026-04-05 at 11:00 (settle)
  When the query is:
    """
    SELECT (COUNT(DISTINCT ?snapshot) AS ?syncs) (COUNT(DISTINCT ?setHash) AS ?setHashes) WHERE {
      GRAPH ?file { ?snapshot a cascade:Snapshot ; prov:wasGeneratedBy ?sync ; cascade:setHash ?setHash .
                    ?sync a cascade:SyncFromAnotherWriter }
    }
    """
  Then it answers:
    | syncs | setHashes |
    | 2     | 1         |

S6. An arrival after a sync revises each of the record's heads

Ruled by Which revision of a record is current, row heads

Two writers that each imported a record hold, once synced, two revisions of it that none revises: its heads. The next arrival that changes it writes one revision, prov:wasRevisionOf each head, as a git merge names each parent (A5), and one whose version is the record's current one writes none (A4).

Why heads rather than a line. Heads rather than a line let two offline writers both import a correction and merge by union; a maximum over the set needs no walk of the line.

Which revision of a record is current: the whole Why, the alternatives that lost and what would change our mind.

1 example: 1 pass, 0 fail, 0 not run

passan import after two writers imported one export writes one revision revising both
Example: an import after two writers imported one export writes one revision revising both
  Given a new pod for Ada on 2026-01-01 at 09:00
  And a second writer of the pod
  And the export "first-export" is imported on 2026-01-02 at 10:00
  And the steps that follow are the second writer's
  And the export "first-export" is imported on 2026-01-02 at 10:00 (second-import)
  And the second writer receives the files of the first writer on 2026-01-03 at 09:00
  When the export "new-content" is imported on 2026-01-06 at 10:00
  When the query is:
    """
    SELECT (COUNT(DISTINCT ?revision) AS ?revisions) (COUNT(DISTINCT ?head) AS ?revised) WHERE {
      GRAPH <urn:cascade:steps> { <urn:cascade:step:new-content> prov:generated ?file }
      GRAPH ?file { ?revision a cascade:Revision ; prov:wasRevisionOf ?head }
    }
    """
  Then it answers:
    | revisions | revised |
    | 1         | 2       |