Implement durable typed journals, subscriptions, and Reader document connections

Add checked native journal/subscription bindings, managed-reference retention,
bounded history and backpressure, atomic delivery receipts, and fenced hosting.
Preserve source publication prediction and replica reconciliation; subscription
attachment, controls, and delivery remain authoritative in this initial version.

Connect independent manual/Gutenberg document producers to Reader bookshelves
through typed adapters. Add connection inspection, shared provider selection,
authoring documentation, and restart/rejection/fan-out integration coverage.

Verified compiler suite (287 passed, two existing skips), Nix runtime and
PostgreSQL qualification, five example assemblies, headless Reader integration,
Chromium Reader integration, resource pins, formatting, and lint.
No pinned workspace runtime was deployed.
This commit is contained in:
Timothy J. Aveni
2026-09-28 19:35:51 -07:00
parent 0ace71eae6
commit 1e72713ae2
30 changed files with 2949 additions and 2033 deletions
+78 -6
View File
@@ -1789,10 +1789,14 @@ const lowerState = (state: LoweringState, context: StateDeclContext): StateSlotD
valueType: lowerValueType(state, context.valueType()),
storagePolicy: policy.REGISTER()
? { kind: "register" }
: {
kind: "crdt-document",
updateType: lowerValueType(state, policy.valueType()),
},
: policy.JOURNAL()
? { kind: "journal", limits: JSON.parse(text(policy.jsonObject())) }
: policy.SUBSCRIPTION()
? { kind: "subscription", payload: lowerValueType(state, policy.valueType()) }
: {
kind: "crdt-document",
updateType: lowerValueType(state, policy.valueType()),
},
defaultValue,
};
};
@@ -2239,9 +2243,9 @@ const lowerConformanceRule = (state: LoweringState, context: ConformanceDeclCont
);
}
}
} else if (provider.STATE() || provider.EDGE()) {
} else if (provider.STATE() || provider.JOURNAL() || provider.SUBSCRIPTION() || provider.EDGE()) {
const name = identifier(provider.identifier(0));
const expected = provider.STATE() ? "state" : "edge";
const expected = provider.STATE() || provider.JOURNAL() || provider.SUBSCRIPTION() ? "state" : "edge";
// Concrete attachments are registered before rules, so unused rules can
// also check public traversal without waiting for an application.
if (provider.EDGE() && !privateStorage.has(name)) {
@@ -2435,6 +2439,74 @@ const lowerConformanceBody = (
return [];
}
const provider = bindingContext.operationProvider();
if (provider.SUBSCRIPTION()) {
const attachment = requireSymbol(
state,
state.attachments,
identifier(provider.identifier(0)),
provider,
"attachment",
);
const primitive = identifier(provider.identifier(1));
if (
!attachment ||
attachment.attachment.kind !== "state" ||
attachment.attachment.storagePolicy.kind !== "subscription" ||
!["attach", "status", "pause", "resume", "retire"].includes(primitive)
) {
loweringIssue(
state,
provider,
"invalid-subscription-binding",
"Expected native subscription storage and a public subscription primitive",
);
return [];
}
return [
{
operationId,
binding: {
kind: "subscription",
slotId: attachment.attachment.id,
primitive: primitive as "attach" | "status" | "pause" | "resume" | "retire",
},
},
];
}
if (provider.JOURNAL()) {
const attachment = requireSymbol(
state,
state.attachments,
identifier(provider.identifier(0)),
provider,
"attachment",
);
const primitive = identifier(provider.identifier(1));
if (
!attachment ||
attachment.attachment.kind !== "state" ||
attachment.attachment.storagePolicy.kind !== "journal" ||
!["publish", "readPage", "head"].includes(primitive)
) {
loweringIssue(
state,
provider,
"invalid-journal-binding",
"Expected a native journal and publish, readPage or head",
);
return [];
}
return [
{
operationId,
binding: {
kind: "journal",
slotId: attachment.attachment.id,
primitive: primitive as "publish" | "readPage" | "head",
},
},
];
}
if (provider.LIFECYCLE()) {
if (identifier(provider.identifier(0)) !== "delete") {
loweringIssue(state, provider, "invalid-lifecycle-binding", "Only lifecycle.delete is supported");