@amalgm/shell 0.1.164-main.42292296991 → 0.1.164-main.42444320985
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PURPOSE.md +51 -93
- package/dist/accepted-tail.d.ts +2 -1
- package/dist/accepted-tail.js +6 -3
- package/dist/accepted-tail.js.map +1 -1
- package/dist/accepted-view.d.ts +27 -0
- package/dist/accepted-view.js +8 -0
- package/dist/accepted-view.js.map +1 -0
- package/dist/apply-enter-plan.d.ts +8 -4
- package/dist/apply-enter-plan.js +24 -5
- package/dist/apply-enter-plan.js.map +1 -1
- package/dist/apply-local-work.d.ts +10 -4
- package/dist/apply-local-work.js +11 -7
- package/dist/apply-local-work.js.map +1 -1
- package/dist/apply-map.js +2 -65
- package/dist/apply-map.js.map +1 -1
- package/dist/apply-window-lane.d.ts +14 -11
- package/dist/apply-window-lane.js +59 -62
- package/dist/apply-window-lane.js.map +1 -1
- package/dist/apply-window-saves.js +2 -2
- package/dist/apply-window-saves.js.map +1 -1
- package/dist/apply-window-store.d.ts +1 -1
- package/dist/apply-window-store.js +3 -3
- package/dist/apply-window-store.js.map +1 -1
- package/dist/authority-binding.d.ts +1 -1
- package/dist/authority-binding.js +1 -7
- package/dist/authority-binding.js.map +1 -1
- package/dist/cli.js +1 -2
- package/dist/cli.js.map +1 -1
- package/dist/content-cache-host.d.ts +3 -25
- package/dist/content-cache-host.js +8 -73
- package/dist/content-cache-host.js.map +1 -1
- package/dist/content-cache-retention.js +1 -2
- package/dist/content-cache-retention.js.map +1 -1
- package/dist/content-capture-pool.d.ts +4 -14
- package/dist/content-capture-pool.js +9 -13
- package/dist/content-capture-pool.js.map +1 -1
- package/dist/content-capture-worker.js +3 -3
- package/dist/content-capture-worker.js.map +1 -1
- package/dist/detection/admission-save.d.ts +5 -1
- package/dist/detection/admission-save.js +6 -1
- package/dist/detection/admission-save.js.map +1 -1
- package/dist/detection/policy-owed.d.ts +1 -1
- package/dist/detection/policy-owed.js +6 -1
- package/dist/detection/policy-owed.js.map +1 -1
- package/dist/detection/root-examination.js +0 -3
- package/dist/detection/root-examination.js.map +1 -1
- package/dist/detection/root-walk.d.ts +3 -10
- package/dist/detection/root-walk.js +18 -26
- package/dist/detection/root-walk.js.map +1 -1
- package/dist/detection/runtime.js +3 -0
- package/dist/detection/runtime.js.map +1 -1
- package/dist/detection/withheld.d.ts +1 -2
- package/dist/detection/withheld.js +2 -5
- package/dist/detection/withheld.js.map +1 -1
- package/dist/entity-record-saves.d.ts +3 -0
- package/dist/entity-record-saves.js +2 -0
- package/dist/entity-record-saves.js.map +1 -1
- package/dist/entity-record-store.d.ts +5 -2
- package/dist/entity-record-store.js +10 -3
- package/dist/entity-record-store.js.map +1 -1
- package/dist/files-program/journeys.d.ts +1 -1
- package/dist/files-program/journeys.js +6 -6
- package/dist/files-program/journeys.js.map +1 -1
- package/dist/files-register-host.d.ts +3 -3
- package/dist/files-register-host.js +32 -17
- package/dist/files-register-host.js.map +1 -1
- package/dist/ground-database.js +15 -55
- package/dist/ground-database.js.map +1 -1
- package/dist/ground-install-saves.d.ts +2 -10
- package/dist/ground-install-saves.js +5 -9
- package/dist/ground-install-saves.js.map +1 -1
- package/dist/ground-save-ops.d.ts +0 -7
- package/dist/ground-save-ops.js +0 -7
- package/dist/ground-save-ops.js.map +1 -1
- package/dist/machine-host.d.ts +1 -1
- package/dist/machine-host.js +1 -1
- package/dist/machine-host.js.map +1 -1
- package/dist/native/cloud-files.node +0 -0
- package/dist/native/windows-fs.node +0 -0
- package/dist/own-results.d.ts +24 -0
- package/dist/own-results.js +76 -0
- package/dist/own-results.js.map +1 -0
- package/dist/package-pages.d.ts +38 -0
- package/dist/package-pages.js +71 -0
- package/dist/package-pages.js.map +1 -0
- package/dist/reference-placement.d.ts +0 -36
- package/dist/reference-placement.js +11 -173
- package/dist/reference-placement.js.map +1 -1
- package/dist/registry-graph.d.ts +4 -21
- package/dist/registry-graph.js +4 -60
- package/dist/registry-graph.js.map +1 -1
- package/dist/sha256.d.ts +0 -2
- package/dist/sha256.js +1 -9
- package/dist/sha256.js.map +1 -1
- package/dist/sharing-admission.d.ts +3 -1
- package/dist/sharing-admission.js +20 -10
- package/dist/sharing-admission.js.map +1 -1
- package/dist/user-ground-host.d.ts +34 -97
- package/dist/user-ground-host.js +181 -802
- package/dist/user-ground-host.js.map +1 -1
- package/examinations/fixtures/private-wire-authority.js +40 -300
- package/npm-shrinkwrap.json +6 -6
- package/package.json +5 -5
- package/dist/content-stream-thread.d.ts +0 -65
- package/dist/content-stream-thread.js +0 -100
- package/dist/content-stream-thread.js.map +0 -1
- package/dist/content-stream-worker.d.ts +0 -7
- package/dist/content-stream-worker.js +0 -54
- package/dist/content-stream-worker.js.map +0 -1
- package/dist/declaration-absorption.d.ts +0 -36
- package/dist/declaration-absorption.js +0 -112
- package/dist/declaration-absorption.js.map +0 -1
- package/dist/declaration-chain.d.ts +0 -27
- package/dist/declaration-chain.js +0 -140
- package/dist/declaration-chain.js.map +0 -1
- package/dist/declaration-commit.d.ts +0 -19
- package/dist/declaration-commit.js +0 -31
- package/dist/declaration-commit.js.map +0 -1
- package/dist/declaration-hold.d.ts +0 -23
- package/dist/declaration-hold.js +0 -19
- package/dist/declaration-hold.js.map +0 -1
- package/dist/declaration-journal.d.ts +0 -79
- package/dist/declaration-journal.js +0 -141
- package/dist/declaration-journal.js.map +0 -1
- package/dist/declaration-save.d.ts +0 -25
- package/dist/declaration-save.js +0 -94
- package/dist/declaration-save.js.map +0 -1
- package/dist/graph-publication.d.ts +0 -66
- package/dist/graph-publication.js +0 -100
- package/dist/graph-publication.js.map +0 -1
- package/dist/register-upload-fusion.d.ts +0 -87
- package/dist/register-upload-fusion.js +0 -174
- package/dist/register-upload-fusion.js.map +0 -1
package/PURPOSE.md
CHANGED
|
@@ -33,9 +33,8 @@ is idempotent against it, so a window re-entered after a crash runs the same
|
|
|
33
33
|
steps again (`src/apply-window-recovery.ts`). Root and path coverage
|
|
34
34
|
remain distinct from ownership: the walk leaves each owned cone unread inside its
|
|
35
35
|
root and admits the root's independent units; only a cone containing the root, or
|
|
36
|
-
|
|
37
|
-
refreshed, erased, or admitted through ignore policy.
|
|
38
|
-
recheck exact ownership answers, including absence, alongside the physical and
|
|
36
|
+
a new root's first walk, defer the whole root. No deferred row is
|
|
37
|
+
refreshed, erased, or admitted through ignore policy. A first walk rechecks exact ownership answers, including absence, alongside the physical and
|
|
39
38
|
SQLite basis; a unit walk relies on its lease, which every later Apply effect
|
|
40
39
|
crosses under its ground hold.
|
|
41
40
|
Terminal commit wakes original receipt scopes before private cleanup. A self-owned
|
|
@@ -655,13 +654,13 @@ after adoption.
|
|
|
655
654
|
for queued events, and only then tears down its wire. `files register` and
|
|
656
655
|
`files add` execute inside that same running host, so declaration, SQLite,
|
|
657
656
|
cloud, and Watch work use the established owners rather than constructing a
|
|
658
|
-
second lifecycle. Register waits
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
657
|
+
second lifecycle. Register waits until the authority has accepted its
|
|
658
|
+
workspace's package and reference, with healthy coverage, before it
|
|
659
|
+
returns. An uncapturable repository leaves its ground owed to Detect,
|
|
660
|
+
which records nothing of it; Live's binding and reference stay durable,
|
|
661
|
+
so a retry waits on the same workspace. No package containing a
|
|
662
|
+
`repo.git` without its verified Card + Checkpoint transport is offered.
|
|
663
|
+
The
|
|
665
664
|
watcher established after authoritative materialization remains the one
|
|
666
665
|
ongoing watcher; the CLI never creates and immediately closes a second
|
|
667
666
|
Watch lifecycle. Closing an unchanged watcher does not invent a full scan. A
|
|
@@ -975,10 +974,10 @@ after adoption.
|
|
|
975
974
|
window so the combined cold byte window remains bounded.
|
|
976
975
|
|
|
977
976
|
30. **Files commands converge on one watching runtime.** `amalgm files
|
|
978
|
-
register <workspace>` asks the already-running runtime to
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
977
|
+
register <workspace>` asks the already-running runtime to place the
|
|
978
|
+
workspace's binding, starter policy and reference, then waits while
|
|
979
|
+
ordinary Detect, Record and Send publish the new ground as one package
|
|
980
|
+
record, until the authority's accepted view holds it as its own root.
|
|
982
981
|
`amalgm files add <workspace>` asks that runtime to materialize the selected
|
|
983
982
|
cloud graph, refresh the exact durable reference inventory in core ground,
|
|
984
983
|
and extend its existing Watch coverage before returning. References to
|
|
@@ -1045,61 +1044,38 @@ after adoption.
|
|
|
1045
1044
|
generation consume the rings accumulated during boot. Register
|
|
1046
1045
|
and Watch enumerate the same durable binding inventory, so a missed
|
|
1047
1046
|
notification for rendering the portable reference cannot lose a
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1047
|
+
registration. A bound root with no rows is new ground: Detect walks it
|
|
1048
|
+
once and records it as one package on its root UUID (Live
|
|
1049
|
+
`packageProposals`), every member keeping its own UUID inside the
|
|
1050
|
+
package's pages, beside ordinary creations for its reference and any
|
|
1051
|
+
folder on its way. Ground placed in the home directly is the same new
|
|
1052
|
+
subtree, packaged by the same pass with no command.
|
|
1054
1053
|
Registering ground that encloses workspaces this machine already
|
|
1055
|
-
materializes absorbs each one
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
the same
|
|
1077
|
-
Re-declaring a workspace the accepted view already holds as its own root
|
|
1078
|
-
publishes no head and walks nothing: it proves cargo closure (31) and
|
|
1079
|
-
returns, and Watch continues to own subsequent content changes. Ending
|
|
1080
|
-
any cold command rearms a Watch generation that arrived while that
|
|
1081
|
-
command temporarily suppressed Detect; a successful idempotent proof
|
|
1082
|
-
cannot strand pending suspicion.
|
|
1083
|
-
31. **A cold graph publication proves cargo closure under the current
|
|
1084
|
-
contract.** A replacement of the selected complete logical roots is one
|
|
1085
|
-
atomic cloud operation; unrelated roots already held by authority are
|
|
1086
|
-
preserved there and never retransmitted. Their presence in the resulting
|
|
1087
|
-
portable graph never makes this machine responsible for those content
|
|
1088
|
-
bytes. A graph head never proves cargo: a record in any head may name
|
|
1089
|
-
content sealed only under a prior content contract, whose namespace the
|
|
1090
|
-
current readers never touch. Only the authority's durable seal for the
|
|
1091
|
-
exact (resource, content hash, current content contract) proves an
|
|
1092
|
-
artifact's cargo. Before advancing the head, the machine asks the
|
|
1093
|
-
authority which content heads the declaration names are sealed under the
|
|
1094
|
-
current contract and uploads exactly the remainder; every one is sealed
|
|
1095
|
-
before its journal row exists, so a replay carries only graph pages.
|
|
1096
|
-
Before answering an idempotent re-declaration, it asks the same of every
|
|
1054
|
+
materializes absorbs each one. Every identity is kept inside the new
|
|
1055
|
+
package; only the absorbed root's own record changes: its parentUUID and
|
|
1056
|
+
name become where the enclosing walk found it, and a `workspace` becomes
|
|
1057
|
+
a `folder`. Ground inside a materialized workspace is refused, because
|
|
1058
|
+
that graph already holds it. Overlapping registrations never create a
|
|
1059
|
+
second identity family.
|
|
1060
|
+
Register success is scoped to the selected workspace and its reference:
|
|
1061
|
+
it suspects those two, waits for Detect to prove that cutoff, flushes
|
|
1062
|
+
Send, and reads the accepted view until it holds both, with healthy
|
|
1063
|
+
coverage. It never waits for unrelated Watch traffic to become silent.
|
|
1064
|
+
Re-registering a workspace the accepted view already holds as its own
|
|
1065
|
+
root records nothing: it proves cargo closure (31) and returns, and Watch
|
|
1066
|
+
continues to own subsequent content changes.
|
|
1067
|
+
31. **Cargo closure is proved under the current contract.** A graph head
|
|
1068
|
+
never proves cargo: a record may name content sealed only under a prior
|
|
1069
|
+
content contract, whose namespace the current readers never touch. Only
|
|
1070
|
+
the authority's durable seal for the exact (resource, content hash,
|
|
1071
|
+
current content contract) proves an artifact's cargo. Before Send offers
|
|
1072
|
+
a package, it asks the authority which of the package's artifacts and
|
|
1073
|
+
pages are sealed and uploads exactly the remainder as one cargo stream,
|
|
1074
|
+
the pages after the members, so a new workspace uploads once. Before
|
|
1075
|
+
answering an idempotent re-registration, Register asks the same of every
|
|
1097
1076
|
content head the accepted workspace names and re-ships each lacking one
|
|
1098
1077
|
that its cache or ground still holds exactly. One overtaken here already
|
|
1099
1078
|
travels as its own Record; the stage names how many it could not restore.
|
|
1100
|
-
This remains true when the local materialization boundary has a portable
|
|
1101
|
-
parent outside the local projection.
|
|
1102
|
-
|
|
1103
1079
|
32. **Coverage precedes recovery, and coverage is not currency.** On process
|
|
1104
1080
|
start Watch first opens the same durable root topology, then Detect closes
|
|
1105
1081
|
the interval during which no watcher existed. Healthy handles prove that
|
|
@@ -1312,25 +1288,11 @@ after adoption.
|
|
|
1312
1288
|
record queries. Reconnect subscribes first and catches up second, so a
|
|
1313
1289
|
missed event costs latency but never loses a record.
|
|
1314
1290
|
|
|
1315
|
-
49. **
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
by its workspace, and has exactly three meanings.
|
|
1321
|
-
`pending` and unsubmitted is a local publication intent the authority has
|
|
1322
|
-
never seen; if its captured ground moves it may be deleted and re-derived,
|
|
1323
|
-
and a newer declaration of the same workspace may supersede it. `pending`
|
|
1324
|
-
and submitted has an unknown authority outcome — the same mutation id
|
|
1325
|
-
retries before any lookup reads the head, because it may already be
|
|
1326
|
-
accepted with only the acknowledgement lost, and nothing may supersede
|
|
1327
|
-
it. `rejected` means the authority conclusively refused that mutation; it
|
|
1328
|
-
is never replayed and the next Register of that workspace folds its
|
|
1329
|
-
declaration again beside a new row, transactionally (last write wins).
|
|
1330
|
-
The submitted boundary is durable before the first commit frame leaves.
|
|
1331
|
-
A permanent refusal therefore cannot wedge Register, stale local capture
|
|
1332
|
-
cannot publish old bytes, and an unacknowledged acceptance always recovers
|
|
1333
|
-
through its original mutation id.
|
|
1291
|
+
49. **Graph publication has no queue of its own.** First login's graph is
|
|
1292
|
+
one idempotent `ensure` of the authority's first graph; every later
|
|
1293
|
+
change, a new workspace's package included, is an ordinary Outbox record
|
|
1294
|
+
with its own mutation identity and retry. There is no second publication
|
|
1295
|
+
journal, and one an older Shell left on disk is dropped at open.
|
|
1334
1296
|
|
|
1335
1297
|
50. **The record queues have one prepared SQLite owner.** Shell opens and
|
|
1336
1298
|
prepares the queue connection once for the rail lifetime. Receive commits
|
|
@@ -1553,14 +1515,10 @@ after adoption.
|
|
|
1553
1515
|
and applied prefix, and authority accepts that graph only while `N` is
|
|
1554
1516
|
still the committed delivery tail under the entity-record ordering gate.
|
|
1555
1517
|
|
|
1556
|
-
59. **Shell
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
roots Live did not select. A submitted intent keeps its mutation identity
|
|
1561
|
-
across restart. A journal in any earlier shape names no declaration: an
|
|
1562
|
-
empty one is recreated, and a non-empty one refuses to open rather than
|
|
1563
|
-
drop an unknown authority outcome.
|
|
1518
|
+
59. **Shell keeps the graph head without duplicating the graph.** Live
|
|
1519
|
+
decides the immutable pages and head. Shell keeps only the head it last
|
|
1520
|
+
read; pages are read as immutable content, never written as a second
|
|
1521
|
+
whole-registry snapshot or rebuilt for roots no operation selected.
|
|
1564
1522
|
|
|
1565
1523
|
60. **Runtime binding is proved, never inferred.** A platform adapter adopts
|
|
1566
1524
|
an existing runtime only when Shell's published loopback address answers
|
|
@@ -1817,7 +1775,7 @@ after adoption.
|
|
|
1817
1775
|
contract change derives a new one and the superseded authority never again
|
|
1818
1776
|
orders anything this machine sends or receives. Before convergence reads
|
|
1819
1777
|
any of it, binding the ground to its current authority retires every
|
|
1820
|
-
record, cursor, baseline, Apply fact and intent
|
|
1778
|
+
record, cursor, baseline, Apply fact and intent
|
|
1821
1779
|
of any other authority in one transaction. None of them can mean anything
|
|
1822
1780
|
to the current authority: a pending row would stall Send behind a contract
|
|
1823
1781
|
that no longer decodes, a cursor or resolution would skip the current
|
package/dist/accepted-tail.d.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* machine's delivery receipt and its history floor (graph-heads.ts). N is
|
|
5
5
|
* the receipt, or an earlier position the receipt has passed. The one
|
|
6
6
|
* reducer (AGENTS.md §3.4) folds the statements in that order; the latest
|
|
7
|
-
* result of each entity answers where an identity stands.
|
|
7
|
+
* result of each entity answers where an identity stands. A package states
|
|
8
|
+
* each member of its subtree (package-pages.ts).
|
|
8
9
|
*
|
|
9
10
|
* The Inbox holds every authority record above the floor through the
|
|
10
11
|
* receipt. A tail may begin only at or above that floor: below it this
|
package/dist/accepted-tail.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { decodeAcceptedEntityRecord } from "@amalgm/live";
|
|
2
2
|
import { readDeliveryReceipt } from "./graph-heads.js";
|
|
3
|
+
import { statedResults } from "./package-pages.js";
|
|
3
4
|
export class AcceptedHistoryUnavailableError extends Error {
|
|
4
5
|
after;
|
|
5
6
|
floor;
|
|
@@ -30,9 +31,11 @@ export function readAcceptedTail(database, authorityId, after, until) {
|
|
|
30
31
|
WHERE authority_id = ? AND delivery_sequence > ? AND delivery_sequence <= ?
|
|
31
32
|
ORDER BY delivery_sequence
|
|
32
33
|
`).iterate(authorityId, after, through)) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// A package states its whole subtree; every member is a result here.
|
|
35
|
+
for (const result of statedResults(database, decodeAcceptedEntityRecord(recordJson).change)) {
|
|
36
|
+
accepted.push(result);
|
|
37
|
+
latest.set(result.uuid, result);
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
40
|
return { after, through, accepted, results: [...latest.values()] };
|
|
38
41
|
})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accepted-tail.js","sourceRoot":"","sources":["../src/accepted-tail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accepted-tail.js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AA6B,CAAC;QACpD,KAAK,MAAM,EAAE,UAAU,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC;;;;KAI7C,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,CAAqC,EAAE,CAAC;YAC5E,qEAAqE;YACrE,KAAK,MAAM,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE,0BAA0B,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5F,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACtB,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;IACrE,CAAC,CAAC,EAAE,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accepted view AV: what this machine knows the authority has accepted.
|
|
3
|
+
* It is the committed head H at its delivery watermark M, folded with every
|
|
4
|
+
* record accepted in (M, N] by Live's one reducer (accepted-fold.ts). Local
|
|
5
|
+
* work the authority has not accepted is never part of it.
|
|
6
|
+
*/
|
|
7
|
+
import type { Sha256Hex } from "@amalgm/live";
|
|
8
|
+
import { AcceptedFold } from "./accepted-fold.js";
|
|
9
|
+
import type { AcceptedTail } from "./accepted-tail.js";
|
|
10
|
+
import type { RegistryGraph } from "./registry-graph.js";
|
|
11
|
+
/** The committed head this machine last read from the authority. */
|
|
12
|
+
export interface CloudHead {
|
|
13
|
+
readonly resourceId: string;
|
|
14
|
+
readonly authorityEpoch: number;
|
|
15
|
+
readonly headVersion: number;
|
|
16
|
+
readonly checksum: string;
|
|
17
|
+
/** M: the complete authority prefix the head already contains. */
|
|
18
|
+
readonly deliveryWatermark: number;
|
|
19
|
+
readonly graph: RegistryGraph;
|
|
20
|
+
}
|
|
21
|
+
/** H ⊕ (M, N]: the head, the accepted tail after it, and their fold. */
|
|
22
|
+
export interface AcceptedView {
|
|
23
|
+
readonly head: CloudHead;
|
|
24
|
+
readonly tail: AcceptedTail;
|
|
25
|
+
readonly fold: AcceptedFold;
|
|
26
|
+
}
|
|
27
|
+
export declare function acceptedView(head: CloudHead, tail: AcceptedTail, sha256Hex: Sha256Hex): Promise<AcceptedView>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AcceptedFold } from "./accepted-fold.js";
|
|
2
|
+
export async function acceptedView(head, tail, sha256Hex) {
|
|
3
|
+
if (tail.after !== head.deliveryWatermark) {
|
|
4
|
+
throw new Error("accepted tail does not begin at the head's delivery watermark");
|
|
5
|
+
}
|
|
6
|
+
return { head, tail, fold: await AcceptedFold.open(head.graph, tail.accepted, sha256Hex) };
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=accepted-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accepted-view.js","sourceRoot":"","sources":["../src/accepted-view.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAsBlD,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAAe,EACf,IAAkB,EAClB,SAAoB;IAEpB,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
* rows place it: a file that moved out of a folder as the folder returned
|
|
14
14
|
* stands once, at its new place. The Enter's end takes any earlier row of it
|
|
15
15
|
* that B kept hidden beneath the container out of B (apply-window-saves.ts,
|
|
16
|
-
* unshownBeneath), so Detect never reads its absence as a removal. A fetch
|
|
17
|
-
*
|
|
16
|
+
* unshownBeneath), so Detect never reads its absence as a removal. A fetch
|
|
17
|
+
* lane reads what this computer shows at its cutoff: each member at its newest
|
|
18
|
+
* row within it, with this computer's own newer results over and beneath it
|
|
19
|
+
* (own-results.ts), so nothing it shows is older than the lane and another
|
|
20
|
+
* computer's work never comes before it is received.
|
|
18
21
|
*
|
|
19
22
|
* Beneath a root on demand an Enter shows one unit (Live unitOf): the
|
|
20
23
|
* members whose nearest repository is the target's, read through the closure
|
|
@@ -51,8 +54,9 @@ export interface EnterClosure {
|
|
|
51
54
|
}
|
|
52
55
|
/** The closure an Enter installs, read at its target's delivery position,
|
|
53
56
|
* or at a fetch lane's cutoff, where each member stands at its newest row
|
|
54
|
-
* within it (Live lane.ts)
|
|
55
|
-
* on demand. A missing kept head throws
|
|
57
|
+
* within it (Live lane.ts) or at this computer's own newer result: one unit's
|
|
58
|
+
* when `unit` is the ground of a root on demand. A missing kept head throws
|
|
59
|
+
* ReceivedStateUnavailableError. */
|
|
56
60
|
export declare function readEnterClosure(input: {
|
|
57
61
|
readonly database: Database.Database;
|
|
58
62
|
readonly intent: EntityApplyIntent;
|
package/dist/apply-enter-plan.js
CHANGED
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
* rows place it: a file that moved out of a folder as the folder returned
|
|
14
14
|
* stands once, at its new place. The Enter's end takes any earlier row of it
|
|
15
15
|
* that B kept hidden beneath the container out of B (apply-window-saves.ts,
|
|
16
|
-
* unshownBeneath), so Detect never reads its absence as a removal. A fetch
|
|
17
|
-
*
|
|
16
|
+
* unshownBeneath), so Detect never reads its absence as a removal. A fetch
|
|
17
|
+
* lane reads what this computer shows at its cutoff: each member at its newest
|
|
18
|
+
* row within it, with this computer's own newer results over and beneath it
|
|
19
|
+
* (own-results.ts), so nothing it shows is older than the lane and another
|
|
20
|
+
* computer's work never comes before it is received.
|
|
18
21
|
*
|
|
19
22
|
* Beneath a root on demand an Enter shows one unit (Live unitOf): the
|
|
20
23
|
* members whose nearest repository is the target's, read through the closure
|
|
@@ -35,6 +38,7 @@
|
|
|
35
38
|
* create. It is left out with its subtree; its own records move it.
|
|
36
39
|
*/
|
|
37
40
|
import { CONTAINERS, eachStep, materializableRecordsSteps, placedInRoot, shownUnits, unitOf, } from "@amalgm/live";
|
|
41
|
+
import { readOwnStanding } from "./own-results.js";
|
|
38
42
|
import { readReceivedState } from "./received-state.js";
|
|
39
43
|
import { cachedStatement } from "./sqlite.js";
|
|
40
44
|
import { finishStepsInTurns } from "./turns.js";
|
|
@@ -42,8 +46,9 @@ import { finishStepsInTurns } from "./turns.js";
|
|
|
42
46
|
export const entersContainer = (plan) => plan.play === "enter" && CONTAINERS.has(plan.target.type);
|
|
43
47
|
/** The closure an Enter installs, read at its target's delivery position,
|
|
44
48
|
* or at a fetch lane's cutoff, where each member stands at its newest row
|
|
45
|
-
* within it (Live lane.ts)
|
|
46
|
-
* on demand. A missing kept head throws
|
|
49
|
+
* within it (Live lane.ts) or at this computer's own newer result: one unit's
|
|
50
|
+
* when `unit` is the ground of a root on demand. A missing kept head throws
|
|
51
|
+
* ReceivedStateUnavailableError. */
|
|
47
52
|
export async function readEnterClosure(input) {
|
|
48
53
|
const { database, intent, target } = input;
|
|
49
54
|
const position = intent.cutoff ?? cachedStatement(database, `SELECT delivery_sequence FROM record_inbox
|
|
@@ -58,12 +63,26 @@ export async function readEnterClosure(input) {
|
|
|
58
63
|
if (!state.records.some(record => record.uuid === target.uuid)) {
|
|
59
64
|
throw new Error(`received state at delivery ${position} does not hold Enter target ${target.uuid}`);
|
|
60
65
|
}
|
|
61
|
-
const
|
|
66
|
+
const shown = intent.cutoff === null ? state.records
|
|
67
|
+
: withOwnResults(state.records, readOwnStanding(database, intent.authorityId, position));
|
|
68
|
+
const records = shown.map(record => record.uuid === target.uuid ? target : record);
|
|
62
69
|
const closure = await finishStepsInTurns(materializableRecordsSteps(records, target.uuid));
|
|
63
70
|
const members = input.unit ? unitMembers(closure, target, input.unit, intent.unit) : closure;
|
|
64
71
|
return { position, records: members,
|
|
65
72
|
newer: intent.cutoff === null ? placedLater(database, intent.authorityId, position, members, target.uuid) : new Set() };
|
|
66
73
|
}
|
|
74
|
+
/** The received records with this computer's own newer results over them,
|
|
75
|
+
* and those it places beneath them: what a lane shows at its cutoff. A
|
|
76
|
+
* result that moves a member out leaves it unreached by the closure. */
|
|
77
|
+
function withOwnResults(received, own) {
|
|
78
|
+
const shown = new Map(received.map(record => [record.uuid, own.get(record.uuid) ?? record]));
|
|
79
|
+
for (const uuid of shown.keys()) {
|
|
80
|
+
for (const child of own.children(uuid))
|
|
81
|
+
if (!shown.has(child.uuid))
|
|
82
|
+
shown.set(child.uuid, child);
|
|
83
|
+
}
|
|
84
|
+
return [...shown.values()];
|
|
85
|
+
}
|
|
67
86
|
/** The members, short of the root, whose newest received row on the
|
|
68
87
|
* authority's line comes after `position`. One index seek per member: the
|
|
69
88
|
* members lead, and INDEXED BY refuses an Inbox scan. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-enter-plan.js","sourceRoot":"","sources":["../src/apply-enter-plan.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"apply-enter-plan.js","sourceRoot":"","sources":["../src/apply-enter-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,0BAA0B,EAC1B,YAAY,EACZ,UAAU,EACV,MAAM,GAMP,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EA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I,CAAC,CAAC;IAC/B,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -11,11 +11,17 @@
|
|
|
11
11
|
* whether any receipt is after the target.
|
|
12
12
|
*
|
|
13
13
|
* Most targets meet no local work at all, so one probe of the authority's
|
|
14
|
-
* pending rows and newest receipt answers them before any channel is read.
|
|
14
|
+
* pending rows and newest receipt answers them before any channel is read.
|
|
15
|
+
*
|
|
16
|
+
* A kept member's target is a result, not a position: the kept head's state
|
|
17
|
+
* or this computer's own newer result (own-results.ts). Local work follows
|
|
18
|
+
* it exactly when this computer's newest own result carries another one. */
|
|
19
|
+
import type { CloudEntityRecord } from "@amalgm/live";
|
|
15
20
|
import type Database from "better-sqlite3";
|
|
16
21
|
/** Whether a local record on the entity's channel is after `deliverySequence`. */
|
|
17
22
|
export declare function hasLocalWorkAfter(database: Database.Database, authorityId: string, entityId: string, deliverySequence: number): boolean;
|
|
18
23
|
/** The gate for the retained Inbox row at `globalSequence` on the entity's
|
|
19
|
-
* channel, or
|
|
20
|
-
* watermark, the history floor
|
|
21
|
-
|
|
24
|
+
* channel, or for a kept member's result: whether its newest own result not
|
|
25
|
+
* held at the kept head's watermark, the history floor, is another one. The
|
|
26
|
+
* Apply store's port form. */
|
|
27
|
+
export declare function hasLocalWorkAfterTarget(database: Database.Database, authorityId: string, entityId: string, target: number | CloudEntityRecord): boolean;
|
package/dist/apply-local-work.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readDeliveryReceipt } from "./graph-heads.js";
|
|
2
|
+
import { ownResults } from "./own-results.js";
|
|
2
3
|
import { cachedStatement } from "./sqlite.js";
|
|
3
4
|
/** Whether a local record on the entity's channel is after `deliverySequence`. */
|
|
4
5
|
export function hasLocalWorkAfter(database, authorityId, entityId, deliverySequence) {
|
|
@@ -6,17 +7,20 @@ export function hasLocalWorkAfter(database, authorityId, entityId, deliverySeque
|
|
|
6
7
|
&& channelWorkAfter(database, authorityId, entityId, deliverySequence);
|
|
7
8
|
}
|
|
8
9
|
/** The gate for the retained Inbox row at `globalSequence` on the entity's
|
|
9
|
-
* channel, or
|
|
10
|
-
* watermark, the history floor
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
* channel, or for a kept member's result: whether its newest own result not
|
|
11
|
+
* held at the kept head's watermark, the history floor, is another one. The
|
|
12
|
+
* Apply store's port form. */
|
|
13
|
+
export function hasLocalWorkAfterTarget(database, authorityId, entityId, target) {
|
|
14
|
+
if (typeof target !== "number") {
|
|
15
|
+
const floor = readDeliveryReceipt(database, authorityId)?.floor ?? 0;
|
|
16
|
+
const own = ownResults(database, authorityId, floor, [entityId]).get(entityId);
|
|
17
|
+
return own !== undefined && own.version !== target.version;
|
|
14
18
|
}
|
|
15
19
|
const deliverySequence = cachedStatement(database, `SELECT delivery_sequence FROM record_inbox
|
|
16
20
|
WHERE entity_id = ? AND global_sequence = ? AND authority_id = ?`).pluck()
|
|
17
|
-
.get(entityId,
|
|
21
|
+
.get(entityId, target, authorityId);
|
|
18
22
|
if (deliverySequence === undefined) {
|
|
19
|
-
throw new Error(`Apply local-work target ${entityId}@${
|
|
23
|
+
throw new Error(`Apply local-work target ${entityId}@${target} is not retained`);
|
|
20
24
|
}
|
|
21
25
|
return hasLocalWorkAfter(database, authorityId, entityId, deliverySequence);
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-local-work.js","sourceRoot":"","sources":["../src/apply-local-work.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply-local-work.js","sourceRoot":"","sources":["../src/apply-local-work.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,kFAAkF;AAClF,MAAM,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,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,aAAa,GAAG;;;;2GAIqF,CAAC;AAC5G,MAAM,cAAc,GAAG;;2CAEoB,CAAC;AAE5C,SAAS,gBAAgB,CAAC,QAA2B,EAAE,WAAmB,EAAE,QAAgB,EAC1F,gBAAwB;IACxB,IAAI,eAAe,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrH,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAA8B,CAAC;IACzH,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,sDAAsD,CAAC,CAAC;IAC/G,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,GAAG,gBAAgB,CAAC;AAC3D,CAAC"}
|
package/dist/apply-map.js
CHANGED
|
@@ -49,13 +49,14 @@
|
|
|
49
49
|
* then the drive holds the root's map, and its top is the map's root
|
|
50
50
|
* (drive/mount.ts composeDrive).
|
|
51
51
|
*/
|
|
52
|
-
import { CONTAINERS, DERIVED_PAYLOAD,
|
|
52
|
+
import { CONTAINERS, DERIVED_PAYLOAD, membershipVersion } from "@amalgm/live";
|
|
53
53
|
import { MapIndex, mapEntity } from "@amalgm/live/drive";
|
|
54
54
|
import { readAcceptedTail } from "./accepted-tail.js";
|
|
55
55
|
import { readDeliveryReceipt } from "./graph-heads.js";
|
|
56
56
|
import { STORED_ENTITIES } from "./ground-inventory-schema.js";
|
|
57
57
|
import { readObservedChildren, readObservedEntities } from "./ground-relations.js";
|
|
58
58
|
import { portableGroundRecord } from "./ground-row.js";
|
|
59
|
+
import { ownResults, readOwnStanding } from "./own-results.js";
|
|
59
60
|
import { HeldHeads } from "./received-state.js";
|
|
60
61
|
import { sha256Hex } from "./sha256.js";
|
|
61
62
|
import { cachedStatement } from "./sqlite.js";
|
|
@@ -336,70 +337,6 @@ async function standing(database, authorityId, through, fold, uuids) {
|
|
|
336
337
|
}
|
|
337
338
|
return entries;
|
|
338
339
|
}
|
|
339
|
-
/** For each of `uuids` this computer has recorded since the received prefix
|
|
340
|
-
* at `through` last held its record: the result of its newest Outbox record,
|
|
341
|
-
* neither stamped at nor received by `through`. The authority accepts this
|
|
342
|
-
* computer's records in their order, so that result follows whatever the
|
|
343
|
-
* prefix holds. */
|
|
344
|
-
function ownResults(database, authorityId, through, uuids) {
|
|
345
|
-
const results = new Map();
|
|
346
|
-
const statement = cachedStatement(database, `SELECT o.record_json FROM record_outbox o
|
|
347
|
-
WHERE o.authority_id = ? AND o.entity_id IN (SELECT value FROM json_each(?)) AND ${UNRECEIVED}
|
|
348
|
-
ORDER BY o.local_sequence`).pluck();
|
|
349
|
-
for (let at = 0; at < uuids.length; at += ASKED_AT_ONCE) {
|
|
350
|
-
const asked = JSON.stringify(uuids.slice(at, at + ASKED_AT_ONCE));
|
|
351
|
-
for (const json of statement.all(authorityId, asked, through, through)) {
|
|
352
|
-
const { result } = decodeLocalEntityRecord(json).change;
|
|
353
|
-
results.set(result.uuid, result);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return results;
|
|
357
|
-
}
|
|
358
|
-
function readOwnStanding(database, authorityId, through) {
|
|
359
|
-
// The read walks this authority's unsent rows and its stamps after the
|
|
360
|
-
// newest one the prefix holds, never the retained history or another
|
|
361
|
-
// authority's rows. First acceptances form a prefix of local order, so on
|
|
362
|
-
// the authority's line positions rise with local order
|
|
363
|
-
// (entity-record-store.ts): every stamp the prefix does not hold follows
|
|
364
|
-
// the newest one it does. Each half names the index of its own rows
|
|
365
|
-
// (ground-database.ts), which the planner cannot weigh without statistics.
|
|
366
|
-
const statement = cachedStatement(database, `SELECT o.record_json, o.local_sequence
|
|
367
|
-
FROM record_outbox o INDEXED BY record_outbox_unsent_entities
|
|
368
|
-
WHERE o.authority_id = ? AND o.status = 'pending' AND ${UNRECEIVED}
|
|
369
|
-
UNION ALL SELECT o.record_json, o.local_sequence FROM record_outbox o INDEXED BY record_outbox_receipts
|
|
370
|
-
WHERE o.authority_id = ? AND o.status = 'accepted' AND o.local_sequence > COALESCE((SELECT local_sequence
|
|
371
|
-
FROM record_outbox INDEXED BY record_outbox_receipts
|
|
372
|
-
WHERE authority_id = ? AND status = 'accepted' AND delivery_sequence <= ?
|
|
373
|
-
ORDER BY local_sequence DESC LIMIT 1), 0)
|
|
374
|
-
AND ${UNRECEIVED}
|
|
375
|
-
ORDER BY 2`).pluck();
|
|
376
|
-
const byUuid = new Map();
|
|
377
|
-
for (const json of statement.all(authorityId, through, through, authorityId, authorityId, through, through, through)) {
|
|
378
|
-
const { result } = decodeLocalEntityRecord(json).change;
|
|
379
|
-
byUuid.set(result.uuid, result);
|
|
380
|
-
}
|
|
381
|
-
for (const uuid of readObservedEntities(database, byUuid.keys()).keys())
|
|
382
|
-
byUuid.delete(uuid);
|
|
383
|
-
const byParent = new Map();
|
|
384
|
-
for (const result of byUuid.values()) {
|
|
385
|
-
if (result.parentUUID === null)
|
|
386
|
-
continue;
|
|
387
|
-
const siblings = byParent.get(result.parentUUID);
|
|
388
|
-
if (siblings)
|
|
389
|
-
siblings.push(result);
|
|
390
|
-
else
|
|
391
|
-
byParent.set(result.parentUUID, [result]);
|
|
392
|
-
}
|
|
393
|
-
return { get: uuid => byUuid.get(uuid), children: parentUUID => byParent.get(parentUUID) ?? [] };
|
|
394
|
-
}
|
|
395
|
-
/** An Outbox row `o` whose record the received prefix at the two bound
|
|
396
|
-
* positions does not hold: neither stamped at a position it covers nor
|
|
397
|
-
* received there. */
|
|
398
|
-
const UNRECEIVED = `(o.delivery_sequence IS NULL OR o.delivery_sequence > ?)
|
|
399
|
-
AND NOT EXISTS (SELECT 1 FROM record_inbox i
|
|
400
|
-
WHERE i.entity_id = o.entity_id AND i.mutation_id = o.mutation_id AND i.delivery_sequence <= ?)`;
|
|
401
|
-
/** Entities asked of the Outbox in one statement. */
|
|
402
|
-
const ASKED_AT_ONCE = 1000;
|
|
403
340
|
/** Whether this computer holds an entity: O stores a row for it, shown or
|
|
404
341
|
* hidden. */
|
|
405
342
|
const placed = (database, uuid) => cachedStatement(database, `SELECT 1 FROM ${STORED_ENTITIES} WHERE uuid = ? LIMIT 1`).pluck().get(uuid) !== undefined;
|