@idleware/ringi 0.6.0 → 0.6.1
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/package.json
CHANGED
|
@@ -26,9 +26,18 @@ const refusal = (c, name) => {
|
|
|
26
26
|
const why = unenforceable(c.capabilities ?? []);
|
|
27
27
|
return why && `hub ${name} ${why}, which this ringi ${version()} cannot enforce. Upgrade ringi`;
|
|
28
28
|
};
|
|
29
|
+
// Old contract snapshots stay immutable after an explicit transition. Only ancestors of a readable canonical
|
|
30
|
+
// main may use the old filename; an old current head or a room's attachment is never accepted this way.
|
|
31
|
+
const historicalContract = (store, name, rev) => {
|
|
32
|
+
const head = store.contractHead();
|
|
33
|
+
if (rev === head || !store.extends(rev, head))
|
|
34
|
+
return null;
|
|
35
|
+
contractAt(store, name, head);
|
|
36
|
+
return store.contractFile(rev, 'hub.json');
|
|
37
|
+
};
|
|
29
38
|
// The contract at `rev`, once it passes every gate.
|
|
30
39
|
export const contractAt = (store, name, rev) => {
|
|
31
|
-
const text = store.contractFile(rev, 'contract.json') ?? fail(`hub ${name} has no contract at ${short(rev)}`);
|
|
40
|
+
const text = store.contractFile(rev, 'contract.json') ?? historicalContract(store, name, rev) ?? fail(`hub ${name} has no contract at ${short(rev)}`);
|
|
32
41
|
const c = strictJson(text, `hub ${name}: contract`);
|
|
33
42
|
const why = refusal(c, name);
|
|
34
43
|
if (why)
|