simetra 0.3.0-next.6 → 0.3.0-next.8
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/dist/compiler/index.d.ts +16 -9
- package/dist/compiler/index.js +803 -476
- package/dist/data/index.js +257 -66
- package/dist/model/index.d.ts +9 -3
- package/dist/model/index.js +9 -3
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.js +1 -1
- package/package.json +2 -2
- package/schemas/catalogs.schema.json +3 -26
- package/schemas/documents.schema.json +3 -26
package/dist/data/index.js
CHANGED
|
@@ -834,6 +834,7 @@ function createObjectStore(options) {
|
|
|
834
834
|
const rowChannel = channelOf(entry);
|
|
835
835
|
const rows = /* @__PURE__ */ new Map();
|
|
836
836
|
const tail = /* @__PURE__ */ new Set();
|
|
837
|
+
let nextMark = 0;
|
|
837
838
|
let restored = 0;
|
|
838
839
|
let hidden = 0;
|
|
839
840
|
session.onFlush(() => {
|
|
@@ -1127,6 +1128,7 @@ function createObjectStore(options) {
|
|
|
1127
1128
|
e.removed.divergent = divergent;
|
|
1128
1129
|
if (!divergent && readEpoch >= e.removed.epoch) {
|
|
1129
1130
|
onRemark?.(key);
|
|
1131
|
+
e.removed.proof = readEpoch;
|
|
1130
1132
|
if (!defects.has("repeated-remove-keeps-epoch")) e.removed.epoch = epochs.next();
|
|
1131
1133
|
}
|
|
1132
1134
|
return;
|
|
@@ -1136,7 +1138,9 @@ function createObjectStore(options) {
|
|
|
1136
1138
|
e.lazyEpochs.clear();
|
|
1137
1139
|
e.removed = {
|
|
1138
1140
|
epoch: epochs.next(),
|
|
1139
|
-
divergent
|
|
1141
|
+
divergent,
|
|
1142
|
+
id: nextMark++,
|
|
1143
|
+
proof: readEpoch
|
|
1140
1144
|
};
|
|
1141
1145
|
},
|
|
1142
1146
|
purgeKeys(scope, keys) {
|
|
@@ -1262,7 +1266,9 @@ function createObjectStore(options) {
|
|
|
1262
1266
|
for (const [field, epoch] of init.lazyIn) e.lazyEpochs.set(field, effectiveEpoch(epoch, e.versionEpoch));
|
|
1263
1267
|
if (init.state === "removed") e.removed = {
|
|
1264
1268
|
epoch: at,
|
|
1265
|
-
divergent: false
|
|
1269
|
+
divergent: false,
|
|
1270
|
+
id: nextMark++,
|
|
1271
|
+
proof: at
|
|
1266
1272
|
};
|
|
1267
1273
|
if (init.state === "hidden") {
|
|
1268
1274
|
e.stale.hidden = { epoch: at };
|
|
@@ -2145,6 +2151,7 @@ const HIDDEN_TAB = {
|
|
|
2145
2151
|
"hydration-trust": "defer",
|
|
2146
2152
|
"access-narrowed": "admit",
|
|
2147
2153
|
"target-behind-header": "defer",
|
|
2154
|
+
"owner-header": "defer",
|
|
2148
2155
|
"min-version": "defer",
|
|
2149
2156
|
"value-hidden": "defer",
|
|
2150
2157
|
"row-unfinished": "defer",
|
|
@@ -2747,21 +2754,6 @@ function tracked(source, flight) {
|
|
|
2747
2754
|
};
|
|
2748
2755
|
}
|
|
2749
2756
|
/**
|
|
2750
|
-
* Reads one part and returns its rows; a failed part is `CommandFailure` of
|
|
2751
|
-
* its error. For the callers that read one query at a time.
|
|
2752
|
-
*/
|
|
2753
|
-
async function readOne(source, query) {
|
|
2754
|
-
const [item] = (await source.read([{
|
|
2755
|
-
type: "query",
|
|
2756
|
-
query
|
|
2757
|
-
}])).items;
|
|
2758
|
-
if (item === void 0 || !item.ok || !("rows" in item)) throw new CommandFailure(item !== void 0 && !item.ok ? item.error : { code: "command.internal" });
|
|
2759
|
-
return {
|
|
2760
|
-
...item.rows,
|
|
2761
|
-
epoch: item.epoch
|
|
2762
|
-
};
|
|
2763
|
-
}
|
|
2764
|
-
/**
|
|
2765
2757
|
* The row a partial marker stands for (P4-B spec §4.1): the held row with the
|
|
2766
2758
|
* values of the `copy` attributes the marker carries. Only those attributes
|
|
2767
2759
|
* are taken — key, version and the rest of `copies` are ignored, because a
|
|
@@ -2834,6 +2826,35 @@ async function readRows$1(source, entry, query, snapshot) {
|
|
|
2834
2826
|
};
|
|
2835
2827
|
}
|
|
2836
2828
|
/**
|
|
2829
|
+
* Reads the lines of a tabular section and the header of its owner (card
|
|
2830
|
+
* form) in one call: the batcher sends both parts as one request (row 22,
|
|
2831
|
+
* sync kernel spec §5.14). The first failed part, in the order of the parts,
|
|
2832
|
+
* is the failure of the read.
|
|
2833
|
+
*/
|
|
2834
|
+
async function readSectionWithHeader(source, entry, query, header, snapshot) {
|
|
2835
|
+
const { items } = await source.read([{
|
|
2836
|
+
type: "query",
|
|
2837
|
+
query
|
|
2838
|
+
}, {
|
|
2839
|
+
type: "query",
|
|
2840
|
+
query: header,
|
|
2841
|
+
...snapshot === void 0 ? {} : { known: snapshot.known }
|
|
2842
|
+
}]);
|
|
2843
|
+
const rowsPart = (item) => {
|
|
2844
|
+
if (item === void 0 || !item.ok || !("rows" in item)) throw new CommandFailure(item !== void 0 && !item.ok ? item.error : { code: "command.internal" });
|
|
2845
|
+
return item;
|
|
2846
|
+
};
|
|
2847
|
+
const lines = rowsPart(items[0]);
|
|
2848
|
+
const head = rowsPart(items[1]);
|
|
2849
|
+
return {
|
|
2850
|
+
section: {
|
|
2851
|
+
...lines.rows,
|
|
2852
|
+
epoch: lines.epoch
|
|
2853
|
+
},
|
|
2854
|
+
header: rowsOf(entry, head.rows.rows, head.epoch, snapshot)
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
/**
|
|
2837
2858
|
* Reads rows of the object of `entry` by keys (P4-B spec §6.1, form `keys`) — the single
|
|
2838
2859
|
* path of every re-read by key. The list form goes by `keysPerRequest` keys
|
|
2839
2860
|
* per request; on `response-too-large` a chunk is halved down to one key,
|
|
@@ -4416,10 +4437,6 @@ function startedFlight(state, start) {
|
|
|
4416
4437
|
flightRevision: start.headerRevision,
|
|
4417
4438
|
retryAt: void 0,
|
|
4418
4439
|
answerPending: true,
|
|
4419
|
-
...start.proofAtStart === true && start.headerRevision !== void 0 ? {
|
|
4420
|
-
readRevision: start.headerRevision,
|
|
4421
|
-
readStart: start.epoch
|
|
4422
|
-
} : {},
|
|
4423
4440
|
...start.sentAt === void 0 ? {} : { refreshedAt: start.sentAt }
|
|
4424
4441
|
};
|
|
4425
4442
|
if (state.flight !== void 0) return {
|
|
@@ -4460,10 +4477,29 @@ function lifts(requirement, input) {
|
|
|
4460
4477
|
const other = !input.own && input.coversHeader === true && input.complete === true;
|
|
4461
4478
|
return own || other;
|
|
4462
4479
|
}
|
|
4463
|
-
case "owner-header": return input.own && input.flight === "load" && input.carriedHeader === true;
|
|
4480
|
+
case "owner-header": return input.own && (input.flight === "load" || input.flight === "reread") && input.carriedHeader === true;
|
|
4464
4481
|
}
|
|
4465
4482
|
}
|
|
4466
4483
|
/**
|
|
4484
|
+
* Власна спроба завантаження, що не зняла вимоги шапки (збій чи відкинуте за
|
|
4485
|
+
* епохою): запис пам'ятає ревізію шапки й епоху її старту, як це робив `main`,
|
|
4486
|
+
* але вимога лишається.
|
|
4487
|
+
*/
|
|
4488
|
+
function withTried(requirement, input) {
|
|
4489
|
+
if (requirement.kind === "owner-header" && input.own && (input.flight === "load" || input.flight === "reread") && (input.outcome === "failed" || input.outcome === "discarded-by-epoch") && input.epoch !== void 0) return {
|
|
4490
|
+
...requirement,
|
|
4491
|
+
tried: input.epoch
|
|
4492
|
+
};
|
|
4493
|
+
if (requirement.kind !== "target-behind-header" || !input.own || input.flight !== "load" || requirement.barrier || input.outcome !== "failed" && input.outcome !== "discarded-by-epoch" || input.headerRevision === void 0 || input.epoch === void 0) return requirement;
|
|
4494
|
+
return {
|
|
4495
|
+
...requirement,
|
|
4496
|
+
tried: {
|
|
4497
|
+
revision: input.headerRevision,
|
|
4498
|
+
start: input.epoch
|
|
4499
|
+
}
|
|
4500
|
+
};
|
|
4501
|
+
}
|
|
4502
|
+
/**
|
|
4467
4503
|
* Політ осів. Вимоги знімає лише застосоване читання з доказом потрібного
|
|
4468
4504
|
* виду польоту й старту (`lifts`); збій, відкинуте за епохою, `evicted`,
|
|
4469
4505
|
* `after-purge` і `closed` вимог не знімають і доказу не пишуть. Місця
|
|
@@ -4477,7 +4513,7 @@ function settleFlight(state, input) {
|
|
|
4477
4513
|
const start = startOf(input.evidence);
|
|
4478
4514
|
let next = {
|
|
4479
4515
|
...state,
|
|
4480
|
-
requirements: state.requirements.filter((r) => !lifts(r, input))
|
|
4516
|
+
requirements: state.requirements.filter((r) => !lifts(r, input)).map((r) => withTried(r, input))
|
|
4481
4517
|
};
|
|
4482
4518
|
if (!input.own) return withRevision(state, next);
|
|
4483
4519
|
if (input.sectionRead !== void 0) next = {
|
|
@@ -4494,7 +4530,7 @@ function settleFlight(state, input) {
|
|
|
4494
4530
|
readStart: start,
|
|
4495
4531
|
readRevision: input.headerRevision
|
|
4496
4532
|
};
|
|
4497
|
-
if (input.flight === "load" && input.carriedHeader === true) next = {
|
|
4533
|
+
if ((input.flight === "load" || input.flight === "reread") && input.carriedHeader === true) next = {
|
|
4498
4534
|
...next,
|
|
4499
4535
|
ownerHeaderRead: Math.max(next.ownerHeaderRead ?? -1, start)
|
|
4500
4536
|
};
|
|
@@ -4592,12 +4628,15 @@ function addRequirement(state, requirement) {
|
|
|
4592
4628
|
let merged = requirement;
|
|
4593
4629
|
if (stands !== void 0) {
|
|
4594
4630
|
const since = Math.max(stands.since, requirement.since);
|
|
4595
|
-
if (stands.kind === "target-behind-header")
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4631
|
+
if (stands.kind === "target-behind-header") {
|
|
4632
|
+
const placed = requirement;
|
|
4633
|
+
merged = {
|
|
4634
|
+
...stands,
|
|
4635
|
+
since,
|
|
4636
|
+
barrier: stands.barrier || placed.barrier,
|
|
4637
|
+
tried: stands.tried
|
|
4638
|
+
};
|
|
4639
|
+
} else if (stands.kind === "owner-header" && requirement.kind === "owner-header" && stands.mark === requirement.mark) merged = {
|
|
4601
4640
|
...stands,
|
|
4602
4641
|
since
|
|
4603
4642
|
};
|
|
@@ -4795,6 +4834,18 @@ function diffOwn(ops, scope, o, prev, wanted) {
|
|
|
4795
4834
|
for (const key of prev) if (!next.has(key)) ops.disown(scope, o, key);
|
|
4796
4835
|
return next;
|
|
4797
4836
|
}
|
|
4837
|
+
/**
|
|
4838
|
+
* Правило складу картки: вона бере ключ у власність, коли відповідь
|
|
4839
|
+
* (завантаження чи системне перечитування) несе рядок оголошеного ключа — одне
|
|
4840
|
+
* правило для обох шляхів (рядок 20). `keys` має інше правило стабільності
|
|
4841
|
+
* складу (§6.5): нові ключі лише ставлять `hasNewRows`.
|
|
4842
|
+
*/
|
|
4843
|
+
function ownsDeclaredKeys(s) {
|
|
4844
|
+
return s.form.spec.kind === "card";
|
|
4845
|
+
}
|
|
4846
|
+
function ownDeclaredKeys(ops, scope, s, keys = s.form.keys) {
|
|
4847
|
+
s.owned = diffOwn(ops, scope, s.form.object, s.owned, keys);
|
|
4848
|
+
}
|
|
4798
4849
|
function setLayout(s, layout) {
|
|
4799
4850
|
s.layout = layout;
|
|
4800
4851
|
s.layoutSet = new Set(layout);
|
|
@@ -5221,7 +5272,7 @@ async function readKeysForm(ctx, s, readEpoch) {
|
|
|
5221
5272
|
got.add(row.key);
|
|
5222
5273
|
}
|
|
5223
5274
|
for (const key of form.keys) if (!got.has(key)) missed(ops, scope, o, key, readEpoch);
|
|
5224
|
-
|
|
5275
|
+
ownDeclaredKeys(ops, scope, s, form.keys);
|
|
5225
5276
|
setLayout(s, form.keys.filter((k) => s.owned.has(k)));
|
|
5226
5277
|
};
|
|
5227
5278
|
}
|
|
@@ -5243,7 +5294,7 @@ async function readCard(ctx, s, readEpoch) {
|
|
|
5243
5294
|
return (scope) => {
|
|
5244
5295
|
if (row !== void 0) ops.put(scope, o, row, readEpoch, true);
|
|
5245
5296
|
else missed(ops, scope, o, key, readEpoch);
|
|
5246
|
-
|
|
5297
|
+
ownDeclaredKeys(ops, scope, s, [key]);
|
|
5247
5298
|
if (form.include.length === 0) return;
|
|
5248
5299
|
const alive = o.rows.get(key)?.removed === void 0 && row !== void 0;
|
|
5249
5300
|
applyIncluded(ctx, scope, s, aliveIncluded(included, includeKeys(form.include, alive ? [row.values] : [])), readEpoch);
|
|
@@ -5254,21 +5305,35 @@ async function readSection(ctx, s, readEpoch) {
|
|
|
5254
5305
|
const o = s.form.object;
|
|
5255
5306
|
const spec = s.form.spec;
|
|
5256
5307
|
const section = o.entry.tabularSections.find((t) => t.name === spec.section);
|
|
5257
|
-
const
|
|
5308
|
+
const answer = await readSectionWithHeader(ctx.source, o.entry, {
|
|
5258
5309
|
object: o.ref,
|
|
5259
5310
|
tabularSection: spec.section,
|
|
5260
5311
|
owner: spec.owner
|
|
5261
|
-
}
|
|
5312
|
+
}, {
|
|
5313
|
+
object: o.ref,
|
|
5314
|
+
id: spec.owner
|
|
5315
|
+
}, o.rows.knownFor([spec.owner], {
|
|
5316
|
+
owned: s.owned,
|
|
5317
|
+
form: "card"
|
|
5318
|
+
}));
|
|
5319
|
+
const result = answer.section;
|
|
5320
|
+
const header = answer.header.find((r) => r.key === spec.owner);
|
|
5262
5321
|
const lines = result.rows.map((values) => lineOf(section, values));
|
|
5263
5322
|
return (scope, report) => {
|
|
5264
|
-
if (report !== void 0)
|
|
5323
|
+
if (report !== void 0) {
|
|
5324
|
+
report.sectionRead = readEpoch;
|
|
5325
|
+
report.carriedHeader = true;
|
|
5326
|
+
}
|
|
5265
5327
|
s.headerState = void 0;
|
|
5328
|
+
if (header !== void 0) ops.put(scope, o, header, readEpoch, true);
|
|
5329
|
+
else missed(ops, scope, o, spec.owner, readEpoch);
|
|
5330
|
+
s.owned = diffOwn(ops, scope, o, s.owned, [spec.owner]);
|
|
5266
5331
|
if (result.ownerVersion === void 0) {
|
|
5267
5332
|
ops.clearOwner(scope, o, spec.owner);
|
|
5268
5333
|
return;
|
|
5269
5334
|
}
|
|
5270
|
-
const
|
|
5271
|
-
if (ops.putSection(scope, o, spec.owner, spec.section, lines, result.ownerVersion, result.epoch, readEpoch, o.entry.scopeColumn === void 0 ? null :
|
|
5335
|
+
const held = o.rows.get(spec.owner);
|
|
5336
|
+
if (ops.putSection(scope, o, spec.owner, spec.section, lines, result.ownerVersion, result.epoch, readEpoch, o.entry.scopeColumn === void 0 ? null : held === void 0 || differentEpochs(result.epoch, held.versionEpoch) || held.version !== result.ownerVersion ? "unknown" : held.scope) === "barred" && report !== void 0) report.sectionRead = void 0;
|
|
5272
5337
|
};
|
|
5273
5338
|
}
|
|
5274
5339
|
/**
|
|
@@ -5352,6 +5417,12 @@ function requirementHold(s) {
|
|
|
5352
5417
|
* Збій читання тут не повторює: його повторює пауза збоїв.
|
|
5353
5418
|
*/
|
|
5354
5419
|
function settleTarget(s, flight, outcome, failure, context) {
|
|
5420
|
+
if (context.unconfirmedSince !== void 0 && !("part" in s)) {
|
|
5421
|
+
s.needsRefresh = true;
|
|
5422
|
+
requireConfirmation(s, context.unconfirmedSince);
|
|
5423
|
+
s.targetState = derivedInputChanged(s.targetState, "registry-flag");
|
|
5424
|
+
return false;
|
|
5425
|
+
}
|
|
5355
5426
|
const rules = rulesOf(flight);
|
|
5356
5427
|
const loadedBefore = "part" in s ? true : s.loaded;
|
|
5357
5428
|
const counts = (applied) => applied ? rules.successMovesDeadline : context.readFailed && (rules.failureCounts === "always" || rules.failureCounts === "if-loaded" && loadedBefore);
|
|
@@ -5364,10 +5435,13 @@ function settleTarget(s, flight, outcome, failure, context) {
|
|
|
5364
5435
|
epoch: required(flight.epoch, "its start epoch")
|
|
5365
5436
|
} : void 0,
|
|
5366
5437
|
own: true,
|
|
5438
|
+
epoch: required(flight.epoch, "its start epoch"),
|
|
5439
|
+
...flight.kind === "load" && s.targetState.flightRevision !== void 0 ? { headerRevision: s.targetState.flightRevision } : {},
|
|
5367
5440
|
startedAt: sentAt ?? (counts(applied) ? required(flight.startedAt, "its start time") : flight.startedAt ?? 0),
|
|
5368
5441
|
loaded: loadedBefore,
|
|
5369
5442
|
applyFailed: !context.readFailed,
|
|
5370
|
-
...context.report?.sectionRead === void 0 ? {} : { sectionRead: context.report.sectionRead }
|
|
5443
|
+
...context.report?.sectionRead === void 0 ? {} : { sectionRead: context.report.sectionRead },
|
|
5444
|
+
...context.report?.carriedHeader === true ? { carriedHeader: true } : {}
|
|
5371
5445
|
});
|
|
5372
5446
|
if ("part" in s) {
|
|
5373
5447
|
if (outcome === "applied" || outcome === "failed") s.targetState = settleFlight(s.targetState, settle(outcome === "applied"));
|
|
@@ -5376,6 +5450,12 @@ function settleTarget(s, flight, outcome, failure, context) {
|
|
|
5376
5450
|
if (outcome === "applied") {
|
|
5377
5451
|
if (rules.successMovesDeadline && rules.confirms === "view-with-composition") s.loaded = true;
|
|
5378
5452
|
s.targetState = settleFlight(s.targetState, settle(true));
|
|
5453
|
+
for (const { target, complete } of context.covered ?? []) target.targetState = settleFlight(target.targetState, {
|
|
5454
|
+
...settle(true),
|
|
5455
|
+
own: false,
|
|
5456
|
+
coversHeader: true,
|
|
5457
|
+
complete
|
|
5458
|
+
});
|
|
5379
5459
|
if (rules.confirms === "view-with-composition" || s.status === "error") {
|
|
5380
5460
|
s.status = "ready";
|
|
5381
5461
|
s.error = void 0;
|
|
@@ -5393,6 +5473,10 @@ function settleTarget(s, flight, outcome, failure, context) {
|
|
|
5393
5473
|
s.status = "error";
|
|
5394
5474
|
s.error = errorOf(failure.error);
|
|
5395
5475
|
}
|
|
5476
|
+
if (outcome === "discarded-by-epoch") s.targetState = settleFlight(s.targetState, {
|
|
5477
|
+
...settle(false),
|
|
5478
|
+
outcome: "discarded-by-epoch"
|
|
5479
|
+
});
|
|
5396
5480
|
return false;
|
|
5397
5481
|
}
|
|
5398
5482
|
const CHECK_ON_MOUNT = {
|
|
@@ -5481,7 +5565,8 @@ function createRegistry(ctx) {
|
|
|
5481
5565
|
const again = settleTarget(s, f, outcome, failure, {
|
|
5482
5566
|
readFailed: entry.failure !== void 0,
|
|
5483
5567
|
tabHidden: ctx.tabHidden,
|
|
5484
|
-
...entry.report === void 0 ? {} : { report: entry.report }
|
|
5568
|
+
...entry.report === void 0 ? {} : { report: entry.report },
|
|
5569
|
+
...outcome === "applied" ? { covered: coveredBy(s) } : {}
|
|
5485
5570
|
});
|
|
5486
5571
|
if (outcome === "applied") verdict.again = again;
|
|
5487
5572
|
},
|
|
@@ -5551,7 +5636,6 @@ function createRegistry(ctx) {
|
|
|
5551
5636
|
cause: why,
|
|
5552
5637
|
epoch: readEpoch,
|
|
5553
5638
|
retry: true,
|
|
5554
|
-
proofAtStart: true,
|
|
5555
5639
|
...header === void 0 ? {} : { headerRevision: rowViews.revision(s.form.object.name, header) }
|
|
5556
5640
|
});
|
|
5557
5641
|
const verdict = {
|
|
@@ -5798,11 +5882,10 @@ function createRegistry(ctx) {
|
|
|
5798
5882
|
* been one) came after the start of its last read: the read cannot have
|
|
5799
5883
|
* seen it, so the re-read is not a repeat of a discarded answer.
|
|
5800
5884
|
*/
|
|
5801
|
-
function hiddenSinceRead(s) {
|
|
5885
|
+
function hiddenSinceRead(s, start = s.targetState.readStart ?? -1) {
|
|
5802
5886
|
const spec = s.form.spec;
|
|
5803
5887
|
if (spec.kind !== "section") return false;
|
|
5804
5888
|
const o = s.form.object;
|
|
5805
|
-
const start = s.targetState.readStart ?? -1;
|
|
5806
5889
|
return hiddenAfter(o, spec.owner, start) || session.epochs.evictedSince(keyId(o.name, spec.owner), start);
|
|
5807
5890
|
}
|
|
5808
5891
|
/**
|
|
@@ -5822,19 +5905,103 @@ function createRegistry(ctx) {
|
|
|
5822
5905
|
});
|
|
5823
5906
|
return;
|
|
5824
5907
|
}
|
|
5825
|
-
|
|
5908
|
+
placeBehindHeader(s);
|
|
5909
|
+
placeOwnerHeader(s);
|
|
5910
|
+
if (readsBehindHeader(s)) load(s, why);
|
|
5911
|
+
else if (readsOwnerHeader(s)) load(s, why.reason === "requirement" ? {
|
|
5912
|
+
...why,
|
|
5913
|
+
requirement: "owner-header"
|
|
5914
|
+
} : why);
|
|
5826
5915
|
}
|
|
5827
5916
|
/**
|
|
5828
|
-
* Картка чи ТЧ відстала від шапки
|
|
5829
|
-
*
|
|
5917
|
+
* Картка чи ТЧ відстала від шапки — умова постановки вимоги «ціль відстала
|
|
5918
|
+
* від шапки» (рядок 20, Р-SK3-11): ціль неповна за `cardStale`/`sectionStale`,
|
|
5919
|
+
* а шапка змінилась (ревізія), чи `hide` власника новіший за застосоване
|
|
5920
|
+
* завантаження. Дешеві перевірки — першими: умова питається на кожен `commit`.
|
|
5830
5921
|
*/
|
|
5831
|
-
function
|
|
5922
|
+
function headerChanged(s) {
|
|
5832
5923
|
const header = headerKey(s);
|
|
5833
5924
|
if (header === void 0) return false;
|
|
5834
|
-
if (!(s.form.spec.kind === "card" ? cardStale(s) : sectionStale(s))) return false;
|
|
5835
5925
|
return rowViews.revision(s.form.object.name, header) !== s.targetState.readRevision || hiddenSinceRead(s);
|
|
5836
5926
|
}
|
|
5837
5927
|
/**
|
|
5928
|
+
* Ставить вимогу «ціль відстала від шапки» (збережена, знімає її лише
|
|
5929
|
+
* осідання з доказом). Стоячу вимогу не зсуває: читання, що вже летить зі
|
|
5930
|
+
* стартом після неї, її знімає, а нова зміна шапки після його старту ставить
|
|
5931
|
+
* вимогу наново (доказ шапки — ревізія на старті, див. `headerChanged`).
|
|
5932
|
+
*/
|
|
5933
|
+
function placeBehindHeader(s) {
|
|
5934
|
+
if (!s.alive || s.purged || headerKey(s) === void 0) return;
|
|
5935
|
+
if (requirementOf(s.targetState, "target-behind-header") !== void 0) return;
|
|
5936
|
+
if (!headerChanged(s)) return;
|
|
5937
|
+
if (!(s.form.spec.kind === "card" ? cardStale(s) : sectionStale(s))) return;
|
|
5938
|
+
s.targetState = addRequirement(s.targetState, {
|
|
5939
|
+
kind: "target-behind-header",
|
|
5940
|
+
since: session.epochs.now(),
|
|
5941
|
+
barrier: false,
|
|
5942
|
+
tried: void 0
|
|
5943
|
+
});
|
|
5944
|
+
}
|
|
5945
|
+
/**
|
|
5946
|
+
* Стоїть вимога шапки, і її є що читати: спроби ще не було, або шапка (ревізія
|
|
5947
|
+
* чи `hide` власника) змінилась після старту спроби, що збилась. Власний `commit` збою чи відкинутого
|
|
5948
|
+
* завантаження повтору не дає (ревізія та сама), як на `main`.
|
|
5949
|
+
*/
|
|
5950
|
+
function readsBehindHeader(s) {
|
|
5951
|
+
const stands = requirementOf(s.targetState, "target-behind-header");
|
|
5952
|
+
if (stands === void 0) return false;
|
|
5953
|
+
const header = headerKey(s);
|
|
5954
|
+
return stands.tried === void 0 || header !== void 0 && rowViews.revision(s.form.object.name, header) !== stands.tried.revision || hiddenSinceRead(s, stands.tried.start);
|
|
5955
|
+
}
|
|
5956
|
+
/**
|
|
5957
|
+
* Ставить вимогу «шапка власника» (рядок 22, Р-SK3-12): власник ТЧ `removed`
|
|
5958
|
+
* позначкою, яку не покриває доказ запису цілі. Позначку покриває читання ТЧ
|
|
5959
|
+
* з шапкою, що стартувало не раніше читання, яке її поставило (власна
|
|
5960
|
+
* позначка завантаження покрита ним самим); `since` — епоха позначки, тож
|
|
5961
|
+
* доказ — читання після неї. Повторна позначка того самого ідентифікатора
|
|
5962
|
+
* зсуває лише `since`.
|
|
5963
|
+
*/
|
|
5964
|
+
function placeOwnerHeader(s) {
|
|
5965
|
+
const spec = s.form.spec;
|
|
5966
|
+
if (!s.alive || s.purged || spec.kind !== "section") return;
|
|
5967
|
+
const mark = s.form.object.rows.get(spec.owner)?.removed;
|
|
5968
|
+
if (mark === void 0) return;
|
|
5969
|
+
const proved = s.targetState.ownerHeaderRead;
|
|
5970
|
+
if (proved !== void 0 && proved >= mark.proof) return;
|
|
5971
|
+
const stands = requirementOf(s.targetState, "owner-header");
|
|
5972
|
+
if (stands !== void 0 && stands.mark === mark.id && stands.since >= mark.epoch) return;
|
|
5973
|
+
s.targetState = addRequirement(s.targetState, {
|
|
5974
|
+
kind: "owner-header",
|
|
5975
|
+
since: mark.epoch,
|
|
5976
|
+
mark: mark.id,
|
|
5977
|
+
tried: void 0
|
|
5978
|
+
});
|
|
5979
|
+
}
|
|
5980
|
+
/**
|
|
5981
|
+
* Вимога шапки власника стоїть, і її є що читати: спроби ще не було, або
|
|
5982
|
+
* позначка повторена після старту спроби, що збилась. Власний `commit` збою
|
|
5983
|
+
* чи відкинутого завантаження повтору не дає.
|
|
5984
|
+
*/
|
|
5985
|
+
function readsOwnerHeader(s) {
|
|
5986
|
+
const stands = requirementOf(s.targetState, "owner-header");
|
|
5987
|
+
return stands !== void 0 && (stands.tried === void 0 || stands.since > stands.tried);
|
|
5988
|
+
}
|
|
5989
|
+
/** Див. `SubsetRegistry.covered`. */
|
|
5990
|
+
function coveredBy(by) {
|
|
5991
|
+
const found = [];
|
|
5992
|
+
for (const t of subsets.values()) {
|
|
5993
|
+
if (t === by || !t.alive || t.purged || t.form.object !== by.form.object) continue;
|
|
5994
|
+
const header = headerKey(t);
|
|
5995
|
+
if (header === void 0 || !by.owned.has(header)) continue;
|
|
5996
|
+
if (requirementOf(t.targetState, "target-behind-header") === void 0) continue;
|
|
5997
|
+
found.push({
|
|
5998
|
+
target: t,
|
|
5999
|
+
complete: !(t.form.spec.kind === "card" ? cardStale(t) : sectionStale(t))
|
|
6000
|
+
});
|
|
6001
|
+
}
|
|
6002
|
+
return found;
|
|
6003
|
+
}
|
|
6004
|
+
/**
|
|
5838
6005
|
* The first hold starts the subset; a card with a stored row shows it
|
|
5839
6006
|
* without a read. A held subset is checked on mount, and a section on
|
|
5840
6007
|
* `preload` too: a stale section (`sectionStale`) is re-read once observed.
|
|
@@ -6147,7 +6314,6 @@ function createRegistry(ctx) {
|
|
|
6147
6314
|
};
|
|
6148
6315
|
}
|
|
6149
6316
|
return {
|
|
6150
|
-
behindHeader: (s) => s.alive && !s.purged && behindHeader(s),
|
|
6151
6317
|
view(spec) {
|
|
6152
6318
|
if (isClosed()) return closedHandle();
|
|
6153
6319
|
const form = formOf(ctx, spec);
|
|
@@ -6195,7 +6361,11 @@ function createRegistry(ctx) {
|
|
|
6195
6361
|
const s = acquire(form);
|
|
6196
6362
|
const o = form.object;
|
|
6197
6363
|
const spec = form.spec;
|
|
6198
|
-
s.owned = diffOwn(ops, scope, o, /* @__PURE__ */ new Set(), [
|
|
6364
|
+
s.owned = diffOwn(ops, scope, o, /* @__PURE__ */ new Set(), [
|
|
6365
|
+
...state.layout,
|
|
6366
|
+
...state.unshown,
|
|
6367
|
+
...spec.kind === "section" ? [spec.owner] : []
|
|
6368
|
+
]);
|
|
6199
6369
|
if (spec.kind !== "card" && spec.kind !== "section") {
|
|
6200
6370
|
s.layout = state.layout.filter((key) => s.owned.has(key));
|
|
6201
6371
|
s.layoutSet = new Set(s.layout);
|
|
@@ -6235,9 +6405,19 @@ function createRegistry(ctx) {
|
|
|
6235
6405
|
if (idle(s)) scheduleRelease(s);
|
|
6236
6406
|
}
|
|
6237
6407
|
},
|
|
6408
|
+
covered: coveredBy,
|
|
6409
|
+
readsByCheck(s) {
|
|
6410
|
+
if (!s.alive || s.purged || s.listeners.size === 0) return false;
|
|
6411
|
+
if (s.targetState.flight !== void 0) return false;
|
|
6412
|
+
placeBehindHeader(s);
|
|
6413
|
+
placeOwnerHeader(s);
|
|
6414
|
+
return readsBehindHeader(s) || readsOwnerHeader(s);
|
|
6415
|
+
},
|
|
6238
6416
|
afterCommit(closing) {
|
|
6239
6417
|
const notify = [];
|
|
6240
6418
|
for (const s of subsets.values()) {
|
|
6419
|
+
placeBehindHeader(s);
|
|
6420
|
+
placeOwnerHeader(s);
|
|
6241
6421
|
if (!closing && snapshotFresh(s) && !affected(s)) continue;
|
|
6242
6422
|
if (snapshotFresh(s)) s.targetState = derivedInputChanged(s.targetState, "affected");
|
|
6243
6423
|
if (s.listeners.size === 0) continue;
|
|
@@ -6550,9 +6730,13 @@ function applyKeys(ctx, s, requested, rows, startEpoch, marksNew) {
|
|
|
6550
6730
|
let fresh = false;
|
|
6551
6731
|
for (const row of rows) {
|
|
6552
6732
|
got.add(row.key);
|
|
6553
|
-
if (s.owned.has(row.key)) ctx.ops.put(scope, o, row, startEpoch, false);
|
|
6733
|
+
if (s.owned.has(row.key) || ownsDeclaredKeys(s) && s.form.keys.includes(row.key)) ctx.ops.put(scope, o, row, startEpoch, false);
|
|
6554
6734
|
else if (!lostSince(ctx, o, row, startEpoch)) fresh = true;
|
|
6555
6735
|
}
|
|
6736
|
+
if (ownsDeclaredKeys(s)) {
|
|
6737
|
+
const brought = rows.map((r) => r.key).filter((k) => s.form.keys.includes(k) && !s.owned.has(k));
|
|
6738
|
+
if (brought.length > 0) ownDeclaredKeys(ctx.ops, scope, s, [...s.owned, ...brought]);
|
|
6739
|
+
}
|
|
6556
6740
|
for (const key of requested) if (!got.has(key) && s.owned.has(key)) ctx.ops.remove(scope, o, key, startEpoch);
|
|
6557
6741
|
if (fresh && marksNew) s.hasNewRows = true;
|
|
6558
6742
|
if (s.form.spec.kind === "keys") rebuildLayout(ctx, s);
|
|
@@ -6933,14 +7117,15 @@ async function revalidateHydrated(ctx, s, why) {
|
|
|
6933
7117
|
* row or an `include` target, invisible views included: the
|
|
6934
7118
|
* values return only with a read that started after the `hide`. A failed
|
|
6935
7119
|
* read leaves them hidden. A view of another object that includes the
|
|
6936
|
-
* object is re-read as its own object's view.
|
|
6937
|
-
*
|
|
7120
|
+
* object is re-read as its own object's view. A tabular section holds the
|
|
7121
|
+
* header of its owner (row 22), so it is re-read here like any holder, unless
|
|
7122
|
+
* the check of the view already reads it for a requirement.
|
|
6938
7123
|
*/
|
|
6939
7124
|
async function revalidateHolders(ctx, object, keys, why) {
|
|
6940
7125
|
const groups = /* @__PURE__ */ new Map();
|
|
6941
7126
|
for (const s of ctx.registry.subsets()) {
|
|
6942
7127
|
if (!s.alive || s.purged || !s.loaded) continue;
|
|
6943
|
-
if (s.form.spec.kind === "section") continue;
|
|
7128
|
+
if (s.form.spec.kind === "section" && ctx.registry.readsByCheck(s)) continue;
|
|
6944
7129
|
const included = s.included.get(object);
|
|
6945
7130
|
if (!(s.form.object.name === object && [...keys].some((k) => s.owned.has(k)) || included !== void 0 && [...keys].some((k) => included.has(k)))) continue;
|
|
6946
7131
|
const read = admitViews(ctx, [s], why);
|
|
@@ -7082,7 +7267,8 @@ async function revalidateViews(ctx, o, reads) {
|
|
|
7082
7267
|
const entry = entryOf.get(flight);
|
|
7083
7268
|
const again = settleTarget(entry.s, flight, outcome, failure, {
|
|
7084
7269
|
readFailed: entry.failure !== void 0,
|
|
7085
|
-
...entry.report === void 0 ? {} : { report: entry.report }
|
|
7270
|
+
...entry.report === void 0 ? {} : { report: entry.report },
|
|
7271
|
+
...outcome === "applied" ? { covered: ctx.registry.covered(entry.s) } : {}
|
|
7086
7272
|
});
|
|
7087
7273
|
if (outcome === "applied" && again) entry.verdict.again = repeatOf(flight, "R18");
|
|
7088
7274
|
},
|
|
@@ -7834,9 +8020,10 @@ function createReceiver(ctx) {
|
|
|
7834
8020
|
token,
|
|
7835
8021
|
what: "writer",
|
|
7836
8022
|
quiet: () => stopped,
|
|
7837
|
-
|
|
7838
|
-
if (rulesOf(flight).keysFailure
|
|
7839
|
-
|
|
8023
|
+
settleTarget: (flight, outcome, _evidence, failure) => {
|
|
8024
|
+
if (entry.failure === void 0 || failure === void 0 || rulesOf(flight).keysFailure !== "composition-unconfirmed") return;
|
|
8025
|
+
for (const s of subsetsOf(writer, entry.job.o)) settleTarget(s, flight, outcome, failure, {
|
|
8026
|
+
readFailed: true,
|
|
7840
8027
|
unconfirmedSince: since
|
|
7841
8028
|
});
|
|
7842
8029
|
},
|
|
@@ -8523,8 +8710,9 @@ function createCore(options) {
|
|
|
8523
8710
|
},
|
|
8524
8711
|
own: (scope, o, key) => o.rows.own(scope, key),
|
|
8525
8712
|
disown(scope, o, key) {
|
|
8713
|
+
const before = o.rows.get(key);
|
|
8526
8714
|
o.rows.disown(scope, key);
|
|
8527
|
-
rowViews.touch(o.name, key);
|
|
8715
|
+
if (before !== void 0 && o.rows.get(key) !== before) rowViews.touch(o.name, key);
|
|
8528
8716
|
},
|
|
8529
8717
|
putSection(scope, o, owner, section, lines, ownerVersion, versionEpoch, readEpoch, ownerScope) {
|
|
8530
8718
|
if (staleObjects.has(o.name)) return void 0;
|
|
@@ -8604,11 +8792,10 @@ function createCore(options) {
|
|
|
8604
8792
|
};
|
|
8605
8793
|
const admitted = source.admit(tailCause, tailTarget, "K3");
|
|
8606
8794
|
if (!isPermit(admitted)) return;
|
|
8607
|
-
|
|
8608
|
-
o.keyQueue
|
|
8609
|
-
const keys = taken.flying;
|
|
8795
|
+
o.keyQueue = keysTaken(queue);
|
|
8796
|
+
const keys = o.keyQueue.flying;
|
|
8610
8797
|
if (keys === void 0) return;
|
|
8611
|
-
const gen =
|
|
8798
|
+
const gen = o.keyQueue.gen;
|
|
8612
8799
|
const token = session.childToken(() => o.keyQueue?.gen === gen);
|
|
8613
8800
|
const extras = {
|
|
8614
8801
|
lease: source.lease(),
|
|
@@ -8657,6 +8844,10 @@ function createCore(options) {
|
|
|
8657
8844
|
runTail(o);
|
|
8658
8845
|
});
|
|
8659
8846
|
}
|
|
8847
|
+
function headerReadBySections(o, key) {
|
|
8848
|
+
const holders = [...registry.subsets()].filter((s) => s.form.object === o && s.owned.has(key));
|
|
8849
|
+
return holders.length > 0 && holders.every((s) => s.form.spec.kind === "section" && registry.readsByCheck(s));
|
|
8850
|
+
}
|
|
8660
8851
|
function scheduleTail(o, keys) {
|
|
8661
8852
|
o.keyQueue = keysQueued(o.keyQueue ?? createKeyQueue(), keys);
|
|
8662
8853
|
runTail(o);
|
|
@@ -8665,7 +8856,7 @@ function createCore(options) {
|
|
|
8665
8856
|
written.length = 0;
|
|
8666
8857
|
const closing = closed !== void 0;
|
|
8667
8858
|
for (const o of objects.values()) {
|
|
8668
|
-
const keys = o.rows.drainTail();
|
|
8859
|
+
const keys = o.rows.drainTail().filter((key) => !headerReadBySections(o, key));
|
|
8669
8860
|
if (keys.length > 0) scheduleTail(o, keys);
|
|
8670
8861
|
}
|
|
8671
8862
|
const barredNow = [...barredSections];
|
|
@@ -9322,7 +9513,6 @@ function createCore(options) {
|
|
|
9322
9513
|
log,
|
|
9323
9514
|
defects
|
|
9324
9515
|
});
|
|
9325
|
-
const TAB_GATED = /* @__PURE__ */ new Set(["channel-rejoin"]);
|
|
9326
9516
|
const VISIBILITY_GATED = /* @__PURE__ */ new Set(["channel-rejoin", "hydration-trust"]);
|
|
9327
9517
|
const causeOf = (why) => {
|
|
9328
9518
|
const { site, ...cause } = why;
|
|
@@ -9382,7 +9572,8 @@ function createCore(options) {
|
|
|
9382
9572
|
epoch: hydrationEpoch
|
|
9383
9573
|
});
|
|
9384
9574
|
if (narrowing.has(s) || beforeFirstViews.has(s)) requirements.push({ kind: "access-narrowed" });
|
|
9385
|
-
if (
|
|
9575
|
+
if (requirementOf(state, "target-behind-header") !== void 0) requirements.push({ kind: "target-behind-header" });
|
|
9576
|
+
if (requirementOf(state, "owner-header") !== void 0) requirements.push({ kind: "owner-header" });
|
|
9386
9577
|
const flights = [];
|
|
9387
9578
|
if (state.flight !== void 0 && state.retryAt === void 0) flights.push({
|
|
9388
9579
|
kind: "load",
|
|
@@ -9410,7 +9601,7 @@ function createCore(options) {
|
|
|
9410
9601
|
const conditionOf = (r) => {
|
|
9411
9602
|
if (r.kind === "composition-unconfirmed") return hold === "absent" ? void 0 : gate.tabHidden() ? "tab-hidden" : hold;
|
|
9412
9603
|
if (r.kind === "hydration-trust" && hydration === "hydrated") return "hydrating";
|
|
9413
|
-
if (gate.tabHidden() && (
|
|
9604
|
+
if (gate.tabHidden() && (HIDDEN_TAB[r.kind] === "defer" || inRetry)) return "tab-hidden";
|
|
9414
9605
|
if (!readable && VISIBILITY_GATED.has(r.kind)) return "target-invisible";
|
|
9415
9606
|
if (promised([r], flights, queued)) return "promised";
|
|
9416
9607
|
return inRetry ? "paused" : void 0;
|
package/dist/model/index.d.ts
CHANGED
|
@@ -751,7 +751,7 @@ export declare const catalogSchema: z.ZodObject<{
|
|
|
751
751
|
dimension: z.ZodString;
|
|
752
752
|
}, z.core.$strict>]>>>;
|
|
753
753
|
ownership: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>>;
|
|
754
|
-
containerBinding: z.ZodOptional<z.
|
|
754
|
+
containerBinding: z.ZodOptional<z.ZodString>;
|
|
755
755
|
rightsContainer: z.ZodOptional<z.ZodBoolean>;
|
|
756
756
|
storage: z.ZodOptional<z.ZodObject<{
|
|
757
757
|
maxBytes: z.ZodInt;
|
|
@@ -1130,7 +1130,7 @@ export declare const documentSchema: z.ZodObject<{
|
|
|
1130
1130
|
dimension: z.ZodString;
|
|
1131
1131
|
}, z.core.$strict>]>>>;
|
|
1132
1132
|
ownership: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>>;
|
|
1133
|
-
containerBinding: z.ZodOptional<z.
|
|
1133
|
+
containerBinding: z.ZodOptional<z.ZodString>;
|
|
1134
1134
|
standardAttributeOverrides: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1135
1135
|
title: z.ZodOptional<z.ZodObject<{
|
|
1136
1136
|
uk: z.ZodOptional<z.ZodString>;
|
|
@@ -2213,6 +2213,12 @@ export declare const customActionsSchema: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
|
2213
2213
|
*/
|
|
2214
2214
|
export declare const rightsCarrierSchema: z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>;
|
|
2215
2215
|
type RightsCarrier = z.infer<typeof rightsCarrierSchema>;
|
|
2216
|
+
/**
|
|
2217
|
+
* Прив'язка до контейнера прав (Р-К1-6): один реквізит-посилання. Ланцюжок
|
|
2218
|
+
* об'єктів будується прив'язкою кожного проміжного об'єкта, а не шляхом у
|
|
2219
|
+
* одному полі: кожен крок — власний об'єкт зі своїми політиками.
|
|
2220
|
+
*/
|
|
2221
|
+
export declare const containerBindingSchema: z.ZodString;
|
|
2216
2222
|
/** Власники рядка (спека прав §4.2): порожній перелік — це відсутність поля. */
|
|
2217
2223
|
export declare const ownershipSchema: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>;
|
|
2218
2224
|
/**
|
|
@@ -3623,8 +3629,8 @@ export declare const projectSchema: z.ZodObject<{
|
|
|
3623
3629
|
en: z.ZodOptional<z.ZodString>;
|
|
3624
3630
|
}, z.core.$strict>>;
|
|
3625
3631
|
defaultLocale: z.ZodDefault<z.ZodEnum<{
|
|
3626
|
-
en: "en";
|
|
3627
3632
|
uk: "uk";
|
|
3633
|
+
en: "en";
|
|
3628
3634
|
}>>;
|
|
3629
3635
|
primaryDataLanguage: z.ZodOptional<z.ZodString>;
|
|
3630
3636
|
defaultSchema: z.ZodDefault<z.ZodString>;
|