@uuaid/pillar 2.7.1 → 2.7.2
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/README.md +30 -9
- package/bin/pillar-directory.mjs +4 -0
- package/package.json +1 -1
- package/src/registry/federation.mjs +6 -0
- package/src/registry/lineage.mjs +51 -16
- package/src/registry/listings.mjs +48 -13
- package/src/registry/stats.mjs +1 -1
- package/src/vnext/verify-cli.mjs +13 -3
package/README.md
CHANGED
|
@@ -717,17 +717,38 @@ a UUAID is read as a file.
|
|
|
717
717
|
|---|---|---|
|
|
718
718
|
| `pillar-responder` | Always-on auto-attendant: acks requests instantly, replies from fixed text or a command hook. Run it as a service; agents anywhere get ack+reply without you being live. | one process, outbound HTTPS |
|
|
719
719
|
| `pillar-seed` | A carrier seed — makes you part of the p2p mesh. Any agent that lists your URL replicates every envelope to you and polls you in parallel with other seeds. `--announce` enrolls it in a seed registry, if one runs `pillar-directory` (see "Running a seed" below). | one process, one SQLite file, TLS-terminating proxy in front |
|
|
720
|
-
| `pillar-directory` | The seed registry: serves `directory.json`, accepts permissionless seed enrollment, probes enrolled seeds, and promotes them. Run one if you publish a directory. **A public registry
|
|
720
|
+
| `pillar-directory` | The seed registry: serves `directory.json`, accepts permissionless seed enrollment, probes enrolled seeds, and promotes them. Run one if you publish a directory. **A public registry runs 2.7.2 or later, up to about 2,000 listings** (note below this table). | one process, one SQLite file |
|
|
721
721
|
| `pillar` | The full CLI (`init`, `id`, `send`, `group`, `groups`, `send-group`, `recv`, `inbox`, `wait`, `readers`, `status`, `receipts`, `trust`, `tier`, `peers`, `delegate`) — optional libp2p DHT, or carrier-only. | only when used interactively |
|
|
722
722
|
|
|
723
|
-
> **Running a public registry (`pillar-directory`)?
|
|
724
|
-
> 2.7.
|
|
725
|
-
>
|
|
726
|
-
> listing
|
|
727
|
-
>
|
|
728
|
-
>
|
|
729
|
-
>
|
|
730
|
-
>
|
|
723
|
+
> **Running a public registry (`pillar-directory`)? Use 2.7.2 or later,
|
|
724
|
+
> not 2.7.0 or 2.7.1, with up to about 2,000 listings.** A 2.7.x registry
|
|
725
|
+
> re-verifies every listing at startup and every 10 minutes, 3.5 to 8 ms per
|
|
726
|
+
> listing (measured). In 2.7.0 and 2.7.1 one request (a refused lineage POST
|
|
727
|
+
> was enough) could make the next `directory.json` do that work, and the
|
|
728
|
+
> registry answered nothing else until it was done. 2.7.2 keeps it off the
|
|
729
|
+
> request path: a refused write leaves the cached verdicts alone, and a
|
|
730
|
+
> verdict stays cached until the next pass refreshes it, however long a
|
|
731
|
+
> pass takes. Two costs remain, both measured on one core:
|
|
732
|
+
>
|
|
733
|
+
> - After a restart, the first `directory.json`, and so a
|
|
734
|
+
> `pillar init --directory` against this registry, waits for the start
|
|
735
|
+
> pass: 3.7 s at 1,000 listings, 19 s at 5,000. Other requests are
|
|
736
|
+
> answered meanwhile.
|
|
737
|
+
> - After each accepted listing, heartbeat or lineage write, the next
|
|
738
|
+
> `directory.json` rebuilds the list: about 0.05 ms per listing (49 ms at
|
|
739
|
+
> 1,000, 141 ms at 3,000), and other requests wait for it. Above about
|
|
740
|
+
> 2,000 listings that passes 100 ms.
|
|
741
|
+
>
|
|
742
|
+
> To stay under about 2,000 listings, start a public registry with
|
|
743
|
+
> `--max-new-lineages-per-hour` (`DIRECTORY_MAX_NEW_LINEAGES_PER_HOUR`) set
|
|
744
|
+
> low, for example 20 (the default is 600), and set it to `0` once the
|
|
745
|
+
> prune log line (`tombstone prune: P of W listings ...`) shows about 2,000:
|
|
746
|
+
> `0` refuses every listing for a lineage the registry does not list yet,
|
|
747
|
+
> and still accepts updates to listed ones.
|
|
748
|
+
>
|
|
749
|
+
> Agents, carriers and private registries can use 2.7.1 or later. The UUAID
|
|
750
|
+
> registry at pillar.uuaid.org is upgraded separately; until then it does
|
|
751
|
+
> not answer /v1/resolve.
|
|
731
752
|
|
|
732
753
|
```sh
|
|
733
754
|
pillar-responder --home ~/.pillar-responder --reply-text "ack" &
|
package/bin/pillar-directory.mjs
CHANGED
|
@@ -343,6 +343,9 @@ const server = createServer(async (req, res) => {
|
|
|
343
343
|
const url = new URL(req.url, `http://${req.headers.host ?? "localhost"}`);
|
|
344
344
|
|
|
345
345
|
if (req.method === "GET" && (url.pathname === "/directory.json" || url.pathname === "/")) {
|
|
346
|
+
// 2.7.2 C2: the start pass fills the lineage memo in yielding slices; until
|
|
347
|
+
// it ends, a projection would verify every listing inside this request.
|
|
348
|
+
await tombstonePruning.firstPass;
|
|
346
349
|
const mergedAgents = listingStore.projectLiveAgents({ staticAgents: agents(), now: getNow() });
|
|
347
350
|
return send(res, 200, registry.directory({ agents: mergedAgents }));
|
|
348
351
|
}
|
|
@@ -361,6 +364,7 @@ const server = createServer(async (req, res) => {
|
|
|
361
364
|
try {
|
|
362
365
|
aggregate = loadRegistryStatsSnapshot(statsDir, registry.uuaid, day, pin);
|
|
363
366
|
if (!aggregate) {
|
|
367
|
+
await tombstonePruning.firstPass; // 2.7.2 C2, as /directory.json
|
|
364
368
|
const projected = listingStore.projectLiveAgents({ staticAgents: agents(), now: getNow() });
|
|
365
369
|
const built = buildRegistryStats(collectRegistryCounts(projected), keychain, { day });
|
|
366
370
|
aggregate = persistFirstRegistryStats(statsDir, built, pin);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uuaid/pillar",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "Pillar (Protocol for Inter-agent Linked Ledger And Relay) — the secure delivery layer of UACP, the Universal Agent Communication Protocol. UACP = UUAID (identity) + Envelope (signed, encrypted container) + Pillar (relay, mailbox, routing, store-and-forward). Reference implementation of the UACP delivery layer; includes VDA-1 (IAASO-3901, in ballot) delivery attestation and a blind escrow for the Zilligon ZGN / EVM rails.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -472,6 +472,9 @@ export class PureJsRegistryDb {
|
|
|
472
472
|
}
|
|
473
473
|
|
|
474
474
|
_flush() {
|
|
475
|
+
// Every write statement below calls flush() once it changed a table, so
|
|
476
|
+
// this counts writes, as SQLite's total_changes() does (2.7.2 R1).
|
|
477
|
+
this._writeCount = (this._writeCount ?? 0) + 1;
|
|
475
478
|
if (!this._persistPath) return;
|
|
476
479
|
mkdirSync(dirname(this._persistPath), { recursive: true });
|
|
477
480
|
const out = {};
|
|
@@ -514,6 +517,9 @@ export class PureJsRegistryDb {
|
|
|
514
517
|
if (norm === "pragma table_info(lineage_event)") {
|
|
515
518
|
return { all: () => [{ name: "complete" }] };
|
|
516
519
|
}
|
|
520
|
+
if (norm === "select total_changes() as n") {
|
|
521
|
+
return { get: () => ({ n: this._writeCount ?? 0 }) };
|
|
522
|
+
}
|
|
517
523
|
|
|
518
524
|
// ---- listing ----
|
|
519
525
|
if (norm === "select * from listing where lineage = ?") {
|
package/src/registry/lineage.mjs
CHANGED
|
@@ -184,9 +184,11 @@ export class LineageStore {
|
|
|
184
184
|
this._lastGlobalSeenMs = 0;
|
|
185
185
|
this._lastSeenMsByLineage = new Map();
|
|
186
186
|
// Read caches (V1 F2): `changes` counts calls that may change stored events
|
|
187
|
-
// or receipts; `_evalMemo` holds evaluateLineageCached results per lineage
|
|
187
|
+
// or receipts; `_evalMemo` holds evaluateLineageCached results per lineage,
|
|
188
|
+
// each stamped with the verify pass current when it was evaluated.
|
|
188
189
|
this.changes = 0;
|
|
189
190
|
this._evalMemo = new Map();
|
|
191
|
+
this._verifyPass = 0;
|
|
190
192
|
|
|
191
193
|
this.db.exec(`
|
|
192
194
|
create table if not exists lineage_event (
|
|
@@ -888,22 +890,45 @@ export class LineageStore {
|
|
|
888
890
|
}
|
|
889
891
|
|
|
890
892
|
/**
|
|
891
|
-
* evaluateLineage, remembered per lineage
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
* forgets its entry (LINEAGE_WRITES).
|
|
895
|
-
*
|
|
896
|
-
*
|
|
893
|
+
* evaluateLineage, remembered per lineage until a verify pass completes
|
|
894
|
+
* without verifying it again (2.7.2 R2, V1 77962b P2). `refresh: true`
|
|
895
|
+
* always evaluates and stores the result (the pass itself uses it). A write
|
|
896
|
+
* to the lineage forgets its entry (LINEAGE_WRITES). Validity is by pass,
|
|
897
|
+
* not wall-clock age: an entry verified by the pass in progress or by the
|
|
898
|
+
* last completed pass is kept, however long a pass takes. Returns the same
|
|
899
|
+
* object for a remembered lineage: callers must not modify it.
|
|
897
900
|
*/
|
|
898
|
-
evaluateLineageCached(lineage, { now,
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
if (hit && nowMs >= hit.atMs && nowMs - hit.atMs < maxAgeMs) return hit.ev; // @rule reg.lineage-eval-memo-age
|
|
901
|
+
evaluateLineageCached(lineage, { now, refresh = false } = {}) {
|
|
902
|
+
const hit = refresh === true ? undefined : this._evalMemo.get(lineage);
|
|
903
|
+
if (hit) return hit.ev;
|
|
902
904
|
const ev = this.evaluateLineage(lineage, { now });
|
|
903
|
-
this._evalMemo.set(lineage, {
|
|
905
|
+
this._evalMemo.set(lineage, { pass: this._verifyPass, ev });
|
|
904
906
|
return ev;
|
|
905
907
|
}
|
|
906
908
|
|
|
909
|
+
/** Start a verify pass (a prune pass over every listing); returns its id. */
|
|
910
|
+
beginVerifyPass() {
|
|
911
|
+
this._verifyPass += 1;
|
|
912
|
+
return this._verifyPass;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* Pass `id` judged every listing: drop the verdicts it did not refresh
|
|
917
|
+
* (verified by an older pass and not since). A stopped or failed pass does
|
|
918
|
+
* not end, so the last completed pass's verdicts stay valid meanwhile.
|
|
919
|
+
*/
|
|
920
|
+
endVerifyPass(id) {
|
|
921
|
+
for (const [lineage, entry] of this._evalMemo) {
|
|
922
|
+
if (entry.pass < id) this._evalMemo.delete(lineage); // @rule reg.lineage-eval-memo-pass
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
/** Rows written on this connection so far (SQLite total_changes(); the pure-JS db counts its writes). */
|
|
927
|
+
_dbWrites() {
|
|
928
|
+
this._totalChangesStmt ??= this.db.prepare("select total_changes() as n");
|
|
929
|
+
return this._totalChangesStmt.get().n;
|
|
930
|
+
}
|
|
931
|
+
|
|
907
932
|
/** A write to `lineage` (unknown: any lineage) happened or may have happened. */
|
|
908
933
|
_noteLineageWrite(lineage) {
|
|
909
934
|
this.changes++;
|
|
@@ -956,8 +981,12 @@ export class LineageStore {
|
|
|
956
981
|
|
|
957
982
|
/**
|
|
958
983
|
* LineageStore methods that may write events or receipts, and the lineage
|
|
959
|
-
* each one writes (undefined = not known: forget every entry).
|
|
960
|
-
*
|
|
984
|
+
* each one writes (undefined = not known: forget every entry). A call is
|
|
985
|
+
* noted (_noteLineageWrite: forget the cached verdict, bump `changes`) only
|
|
986
|
+
* when it wrote a row or threw (2.7.2 R1, V1 77962b P1). Before, every call
|
|
987
|
+
* was noted, accepted or refused, and a refused unauthenticated
|
|
988
|
+
* POST /v1/lineage with no string lineage ({} or null) emptied the whole
|
|
989
|
+
* verdict cache, so the next directory.json re-verified every listing.
|
|
961
990
|
*/
|
|
962
991
|
const LINEAGE_WRITES = {
|
|
963
992
|
storeEvent: (ev) => ev?.lineage,
|
|
@@ -972,10 +1001,16 @@ for (const [name, lineageOf] of Object.entries(LINEAGE_WRITES)) {
|
|
|
972
1001
|
const write = LineageStore.prototype[name];
|
|
973
1002
|
Object.defineProperty(LineageStore.prototype, name, {
|
|
974
1003
|
value: function noted(...args) {
|
|
1004
|
+
const before = this._dbWrites();
|
|
1005
|
+
let threw = true;
|
|
975
1006
|
try {
|
|
976
|
-
|
|
1007
|
+
const res = write.apply(this, args);
|
|
1008
|
+
threw = false;
|
|
1009
|
+
return res;
|
|
977
1010
|
} finally {
|
|
978
|
-
|
|
1011
|
+
let wrote = true;
|
|
1012
|
+
if (!threw && this._dbWrites() === before) wrote = false; // @rule reg.lineage-note-real-writes
|
|
1013
|
+
if (wrote) this._noteLineageWrite(lineageOf(...args));
|
|
979
1014
|
}
|
|
980
1015
|
},
|
|
981
1016
|
writable: true,
|
|
@@ -42,8 +42,18 @@ export const TOMBSTONE_RETENTION_MS = 365 * 86_400_000;
|
|
|
42
42
|
* request path: at start and every PRUNE_INTERVAL_MS (startTombstonePruning).
|
|
43
43
|
* directory.json is rebuilt when a listing, heartbeat or lineage write
|
|
44
44
|
* happened, or after PROJECTION_MAX_AGE_MS (status is a function of time).
|
|
45
|
-
* A rebuild re-verifies only lineages written since, or not verified
|
|
46
|
-
*
|
|
45
|
+
* A rebuild re-verifies only lineages written since, or not verified by the
|
|
46
|
+
* last completed prune pass nor the one in progress; each pass re-verifies
|
|
47
|
+
* all of them.
|
|
48
|
+
*
|
|
49
|
+
* Validity is by pass number, not age (2.7.2 R2, V1 77962b P2). 2.7.1 kept a
|
|
50
|
+
* verdict for one interval from the pass start, so all expired as the next
|
|
51
|
+
* pass started and a rebuild early in it re-verified every row not yet
|
|
52
|
+
* walked, inside the request (V1 cf5902). 2.7.2-r1 doubled the age, which
|
|
53
|
+
* held only while a pass ended within one interval. Now an entry lives until
|
|
54
|
+
* a pass completes without refreshing it, whatever a pass takes. A verdict
|
|
55
|
+
* that changes with time alone reaches directory.json when the next pass
|
|
56
|
+
* reaches its row, plus PROJECTION_MAX_AGE_MS.
|
|
47
57
|
*/
|
|
48
58
|
export const PRUNE_INTERVAL_MS = 10 * 60_000;
|
|
49
59
|
/** Longest stretch a timed prune pass holds the event loop before it yields (V1 P2). */
|
|
@@ -51,7 +61,6 @@ export const PRUNE_SLICE_MS = 20;
|
|
|
51
61
|
|
|
52
62
|
const yieldToEventLoop = () => new Promise((resolve) => setImmediate(resolve));
|
|
53
63
|
export const PROJECTION_MAX_AGE_MS = 60_000;
|
|
54
|
-
export const EVAL_MEMO_MAX_AGE_MS = PRUNE_INTERVAL_MS;
|
|
55
64
|
|
|
56
65
|
const HEX128_RE = /^[0-9a-f]{128}$/;
|
|
57
66
|
const NONCE_RE = /^[0-9a-f]{1,32}$/;
|
|
@@ -445,9 +454,11 @@ export class ListingStore {
|
|
|
445
454
|
const nowStr = nowIso(now);
|
|
446
455
|
const nowMs = Date.parse(nowStr);
|
|
447
456
|
const lineages = [];
|
|
457
|
+
const pass = this.lineageStore ? this.lineageStore.beginVerifyPass() : 0;
|
|
448
458
|
for (const lineage of this._listedLineages()) {
|
|
449
459
|
if (this._pruneOne(lineage, nowStr, nowMs)) lineages.push(lineage);
|
|
450
460
|
}
|
|
461
|
+
if (this.lineageStore) this.lineageStore.endVerifyPass(pass);
|
|
451
462
|
return { pruned: lineages.length, lineages };
|
|
452
463
|
}
|
|
453
464
|
|
|
@@ -456,19 +467,24 @@ export class ListingStore {
|
|
|
456
467
|
* awaits `yieldFn` (setImmediate), so requests are answered during the pass.
|
|
457
468
|
* Each row is re-read and judged inside one slice, so a write that lands
|
|
458
469
|
* between slices is seen. `shouldStop()` ends the pass early (shutdown).
|
|
459
|
-
* Returns { pruned, lineages, rows, slices, longestSliceMs }
|
|
470
|
+
* Returns { pruned, lineages, rows, walked, slices, longestSliceMs }: rows
|
|
471
|
+
* is the number of listings when the pass began, walked the number it
|
|
472
|
+
* judged (less than rows when it was stopped).
|
|
460
473
|
*/
|
|
461
474
|
async pruneExpiredTombstonesYielding({ now, sliceMs = PRUNE_SLICE_MS, yieldFn = yieldToEventLoop, shouldStop = () => false } = {}) {
|
|
462
475
|
const nowStr = nowIso(now);
|
|
463
476
|
const nowMs = Date.parse(nowStr);
|
|
464
477
|
const lineages = [];
|
|
465
478
|
const all = this._listedLineages();
|
|
479
|
+
const pass = this.lineageStore ? this.lineageStore.beginVerifyPass() : 0;
|
|
480
|
+
let walked = 0;
|
|
466
481
|
let slices = 1;
|
|
467
482
|
let longestSliceMs = 0;
|
|
468
483
|
let sliceStart = performance.now();
|
|
469
484
|
for (const lineage of all) {
|
|
470
485
|
if (shouldStop()) break;
|
|
471
486
|
if (this._pruneOne(lineage, nowStr, nowMs)) lineages.push(lineage);
|
|
487
|
+
walked++;
|
|
472
488
|
const spent = performance.now() - sliceStart;
|
|
473
489
|
let yieldNow = false;
|
|
474
490
|
if (spent >= sliceMs) yieldNow = true; // @rule reg.prune-yields
|
|
@@ -480,7 +496,10 @@ export class ListingStore {
|
|
|
480
496
|
}
|
|
481
497
|
}
|
|
482
498
|
longestSliceMs = Math.max(longestSliceMs, performance.now() - sliceStart);
|
|
483
|
-
|
|
499
|
+
// Only a pass that judged every listing ends: a stopped one keeps the last
|
|
500
|
+
// completed pass's verdicts valid (2.7.2 R2).
|
|
501
|
+
if (this.lineageStore && walked === all.length) this.lineageStore.endVerifyPass(pass);
|
|
502
|
+
return { pruned: lineages.length, lineages, rows: all.length, walked, slices, longestSliceMs: Math.round(longestSliceMs) };
|
|
484
503
|
}
|
|
485
504
|
|
|
486
505
|
_listedLineages() {
|
|
@@ -492,8 +511,8 @@ export class ListingStore {
|
|
|
492
511
|
const row = this.getByLineage(lineage);
|
|
493
512
|
if (!row) return false;
|
|
494
513
|
const l = row.listing;
|
|
495
|
-
// A fresh verdict (
|
|
496
|
-
const evalRes = this.lineageStore ? this.lineageStore.evaluateLineageCached(l.lineage, { now: nowStr,
|
|
514
|
+
// A fresh verdict (refresh), kept for the next directory.json rebuild.
|
|
515
|
+
const evalRes = this.lineageStore ? this.lineageStore.evaluateLineageCached(l.lineage, { now: nowStr, refresh: true }) : null;
|
|
497
516
|
let deadSinceMs = null;
|
|
498
517
|
if (evalRes?.tombstoned === true) {
|
|
499
518
|
deadSinceMs = Date.parse(evalRes.tombstoneTs);
|
|
@@ -548,7 +567,7 @@ export class ListingStore {
|
|
|
548
567
|
if (row.withdrawn === 1 || l.withdrawn === true) continue; // @rule reg.project-not-withdrawn
|
|
549
568
|
if (this.hasOtherLineage(l.lineage, l.lineage) || this.hasOtherLineage(l.uuaid, l.lineage)) continue; // @rule reg.project-ambiguous-listing-store
|
|
550
569
|
if (this.lineageStore.hasOtherLineage(l.lineage, l.lineage) || this.lineageStore.hasOtherLineage(l.uuaid, l.lineage)) continue; // @rule reg.project-ambiguous-lineage-store
|
|
551
|
-
const evalRes = this.lineageStore.evaluateLineageCached(l.lineage, { now: nowStr
|
|
570
|
+
const evalRes = this.lineageStore.evaluateLineageCached(l.lineage, { now: nowStr });
|
|
552
571
|
if (evalRes?.tombstoned === true) continue; // @rule reg.project-not-tombstoned
|
|
553
572
|
if (evalRes !== null && ((evalRes.verdict !== "valid" && evalRes.verdict !== "recovered" && evalRes.verdict !== "pending-recovery") || evalRes.current !== l.uuaid)) continue; // @rule reg.project-lineage-current
|
|
554
573
|
const hb = this.heartbeatStore ? this.heartbeatStore.getLatest(l.lineage) : null;
|
|
@@ -572,8 +591,15 @@ export class ListingStore {
|
|
|
572
591
|
* slice runs before this returns; the rest run while the registry serves.
|
|
573
592
|
* One pass at a time; a pass that throws is logged and the timer keeps
|
|
574
593
|
* running. A pass that pruned rows or ran >= 1 s is reported through `info`.
|
|
575
|
-
* Returns { stop, runNow, whenIdle, runs } (runs: the last 10
|
|
576
|
-
* { pruned, rows, ms, slices, longestSliceMs }).
|
|
594
|
+
* Returns { stop, runNow, whenIdle, firstPass, runs } (runs: the last 10
|
|
595
|
+
* passes, { pruned, rows, ms, slices, longestSliceMs }). `firstPass`
|
|
596
|
+
* settles when the start pass ends (pruned, failed or stopped; it never
|
|
597
|
+
* rejects) and the directory.json projection is built: a handler that
|
|
598
|
+
* projects every listing awaits it, so the start pass fills the lineage
|
|
599
|
+
* memo off the request path (2.7.2 C2). The build (about 40 ms at 1,000
|
|
600
|
+
* listings) runs in a tick of its own, with an I/O turn before and after
|
|
601
|
+
* it, so the handlers that waited resume on a cached projection instead
|
|
602
|
+
* of all building and sending in one tick.
|
|
577
603
|
*/
|
|
578
604
|
export function startTombstonePruning(listingStore, { getNow = () => undefined, intervalMs = PRUNE_INTERVAL_MS, sliceMs = PRUNE_SLICE_MS, log = (m) => console.error(m), info = (m) => console.log(m), setIntervalFn = setInterval, clearIntervalFn = clearInterval } = {}) {
|
|
579
605
|
const runs = [];
|
|
@@ -584,9 +610,12 @@ export function startTombstonePruning(listingStore, { getNow = () => undefined,
|
|
|
584
610
|
try {
|
|
585
611
|
const r = await listingStore.pruneExpiredTombstonesYielding({ now: getNow(), sliceMs, shouldStop: () => stopped });
|
|
586
612
|
const ms = Math.round(performance.now() - t0);
|
|
587
|
-
runs.push({ pruned: r.pruned, rows: r.rows, ms, slices: r.slices, longestSliceMs: r.longestSliceMs });
|
|
613
|
+
runs.push({ pruned: r.pruned, rows: r.rows, walked: r.walked, ms, slices: r.slices, longestSliceMs: r.longestSliceMs });
|
|
588
614
|
if (runs.length > 10) runs.shift();
|
|
589
|
-
|
|
615
|
+
// "P of W": W = listings this pass judged. A pass stopped early (shutdown)
|
|
616
|
+
// says so, rather than counting listings it never reached as checked.
|
|
617
|
+
const stoppedEarly = r.walked < r.rows;
|
|
618
|
+
if (r.pruned > 0 || ms >= 1000 || stoppedEarly) info(`[registry] tombstone prune: ${r.pruned} of ${r.walked} listings pruned in ${ms} ms (${r.slices} slices, longest ${r.longestSliceMs} ms)${stoppedEarly ? `; stopped after ${r.walked} of ${r.rows} listings` : ""}`);
|
|
590
619
|
return r;
|
|
591
620
|
} catch (e) {
|
|
592
621
|
if (!stopped) log(`[registry] tombstone prune failed: ${e?.message ?? e}`);
|
|
@@ -600,13 +629,19 @@ export function startTombstonePruning(listingStore, { getNow = () => undefined,
|
|
|
600
629
|
if (!inFlight) inFlight = pass();
|
|
601
630
|
return inFlight;
|
|
602
631
|
};
|
|
603
|
-
runNow()
|
|
632
|
+
const firstPass = runNow().then(async (r) => {
|
|
633
|
+
await yieldToEventLoop();
|
|
634
|
+
try { listingStore.projectLiveAgents({ now: getNow() }); } catch (_e) { /* a store without lineages: the handler reports it */ }
|
|
635
|
+
await yieldToEventLoop();
|
|
636
|
+
return r;
|
|
637
|
+
});
|
|
604
638
|
const timer = setIntervalFn(runNow, intervalMs);
|
|
605
639
|
timer?.unref?.();
|
|
606
640
|
return {
|
|
607
641
|
stop: () => { stopped = true; clearIntervalFn(timer); },
|
|
608
642
|
runNow,
|
|
609
643
|
whenIdle: () => inFlight ?? Promise.resolve(null),
|
|
644
|
+
firstPass,
|
|
610
645
|
runs,
|
|
611
646
|
};
|
|
612
647
|
}
|
package/src/registry/stats.mjs
CHANGED
|
@@ -52,7 +52,7 @@ export const TTFA_METHODS = Object.freeze(["ci-canary", "field-cohort"]);
|
|
|
52
52
|
export const TTFA_MIN_N = 10;
|
|
53
53
|
|
|
54
54
|
/** Tool stamped on B8 verdicts (same string the `pillar verify` CLI uses). */
|
|
55
|
-
export const STATS_VERDICT_TOOL = "pillar/2.7.
|
|
55
|
+
export const STATS_VERDICT_TOOL = "pillar/2.7.2";
|
|
56
56
|
|
|
57
57
|
/** Closed key set of `pillar-ttfa-report/1`. */
|
|
58
58
|
export const TTFA_REPORT_KEYS = Object.freeze([
|
package/src/vnext/verify-cli.mjs
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
verifyStatsArtifact,
|
|
32
32
|
} from "../registry/stats.mjs";
|
|
33
33
|
|
|
34
|
-
export const VERIFY_CLI_TOOL = "pillar/2.7.
|
|
34
|
+
export const VERIFY_CLI_TOOL = "pillar/2.7.2";
|
|
35
35
|
const TYPE_SET = new Set([...VERIFY_TYPES, TTFA_VERDICT_TYPE, REGISTRY_STATS_VERDICT_TYPE]);
|
|
36
36
|
|
|
37
37
|
const VALUE_FLAGS = new Set([
|
|
@@ -289,6 +289,9 @@ export function verifyForm(rawArgs) {
|
|
|
289
289
|
return live ? "uuaid" : "file";
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
/** A pillar-verdict/1 object exitCodeFor can read. */
|
|
293
|
+
const isVerdict = (v) => typeof v === "object" && v !== null && typeof v.verdict === "string";
|
|
294
|
+
|
|
292
295
|
/**
|
|
293
296
|
* `pillar verify <uuaid>`: core resolve (fail-closed) and the lineage verdict
|
|
294
297
|
* it carries. Exit as the file form: exitCodeFor(lineage verdict); 1 when the
|
|
@@ -300,8 +303,15 @@ export async function runVerifyUuaidCli(rawArgs, io = {}) {
|
|
|
300
303
|
const live = await resolveLive(rawArgs, { cmdName: "verify", io });
|
|
301
304
|
if (live.usage) return { exitCode: live.usage.exitCode, verdict: null };
|
|
302
305
|
const { json, registryUrl, uuaid, result, error } = live;
|
|
303
|
-
|
|
304
|
-
|
|
306
|
+
let reason = null;
|
|
307
|
+
if (error !== null) reason = "resolve-error";
|
|
308
|
+
else if (!result || result.ok !== true) reason = result?.reason ?? "failed";
|
|
309
|
+
// 2.7.2 C3 (V1 cf5902 P4): core resolve checks the listing and card but
|
|
310
|
+
// fetches no lineage for a listing-only agent (card without lineageHead,
|
|
311
|
+
// current == lineage == query), so there is no lineage verdict to report.
|
|
312
|
+
// Not verified, rather than exitCodeFor(undefined) and a stack trace.
|
|
313
|
+
if (reason === null && !isVerdict(result.lineageVerdict)) reason = "lineage-not-verified"; // @rule verify-cli.uuaid-needs-lineage-verdict
|
|
314
|
+
if (reason !== null) {
|
|
305
315
|
const report = { ok: false, form: "uuaid", query: uuaid, registry: registryUrl, reason, ...(error !== null ? { message: error } : {}), ...(result?.statusCode ? { statusCode: result.statusCode } : {}) };
|
|
306
316
|
if (json) out(`${JSON.stringify(report)}\n`);
|
|
307
317
|
else errOut(`not verified ${uuaid}: ${reason}${result?.statusCode ? ` (HTTP ${result.statusCode})` : ""}${error !== null ? ` (${error})` : ""} [live, ${registryUrl}]\n`);
|