@origintrail-official/dkg-agent 10.0.22 → 10.0.23
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/approved-private-replica-proof-runs.d.ts +40 -0
- package/dist/approved-private-replica-proof-runs.d.ts.map +1 -0
- package/dist/approved-private-replica-proof-runs.js +49 -0
- package/dist/approved-private-replica-proof-runs.js.map +1 -0
- package/dist/approved-private-replica.d.ts +18 -1
- package/dist/approved-private-replica.d.ts.map +1 -1
- package/dist/approved-private-replica.js +9 -3
- package/dist/approved-private-replica.js.map +1 -1
- package/dist/context-graph-chain-discovery-binding.d.ts +2 -0
- package/dist/context-graph-chain-discovery-binding.d.ts.map +1 -1
- package/dist/context-graph-chain-discovery-binding.js +7 -0
- package/dist/context-graph-chain-discovery-binding.js.map +1 -1
- package/dist/context-graph-dormant-identity.d.ts +8 -0
- package/dist/context-graph-dormant-identity.d.ts.map +1 -0
- package/dist/context-graph-dormant-identity.js +48 -0
- package/dist/context-graph-dormant-identity.js.map +1 -0
- package/dist/context-graph-meta-projection.d.ts +12 -49
- package/dist/context-graph-meta-projection.d.ts.map +1 -1
- package/dist/context-graph-meta-projection.js +71 -24
- package/dist/context-graph-meta-projection.js.map +1 -1
- package/dist/context-graph-name-binding-target.d.ts +21 -0
- package/dist/context-graph-name-binding-target.d.ts.map +1 -0
- package/dist/context-graph-name-binding-target.js +68 -0
- package/dist/context-graph-name-binding-target.js.map +1 -0
- package/dist/context-graph-persisted-name-aliases.d.ts +47 -0
- package/dist/context-graph-persisted-name-aliases.d.ts.map +1 -0
- package/dist/context-graph-persisted-name-aliases.js +173 -0
- package/dist/context-graph-persisted-name-aliases.js.map +1 -0
- package/dist/context-graph-read-authority.d.ts +26 -11
- package/dist/context-graph-read-authority.d.ts.map +1 -1
- package/dist/context-graph-read-authority.js +26 -2
- package/dist/context-graph-read-authority.js.map +1 -1
- package/dist/context-graph-subscription-authority-recovery.d.ts +4 -0
- package/dist/context-graph-subscription-authority-recovery.d.ts.map +1 -1
- package/dist/context-graph-subscription-authority-recovery.js +8 -2
- package/dist/context-graph-subscription-authority-recovery.js.map +1 -1
- package/dist/context-graph-subscription-policy.d.ts +34 -1
- package/dist/context-graph-subscription-policy.d.ts.map +1 -1
- package/dist/context-graph-subscription-policy.js +143 -1
- package/dist/context-graph-subscription-policy.js.map +1 -1
- package/dist/curator-meta-refresh.d.ts.map +1 -1
- package/dist/curator-meta-refresh.js +31 -9
- package/dist/curator-meta-refresh.js.map +1 -1
- package/dist/dkg-agent-base.d.ts.map +1 -1
- package/dist/dkg-agent-base.js +0 -1
- package/dist/dkg-agent-base.js.map +1 -1
- package/dist/dkg-agent-cg-name-resolution.d.ts +6 -24
- package/dist/dkg-agent-cg-name-resolution.d.ts.map +1 -1
- package/dist/dkg-agent-cg-name-resolution.js +42 -58
- package/dist/dkg-agent-cg-name-resolution.js.map +1 -1
- package/dist/dkg-agent-cg-on-chain-id.d.ts +3 -3
- package/dist/dkg-agent-cg-on-chain-id.d.ts.map +1 -1
- package/dist/dkg-agent-cg-on-chain-id.js +7 -23
- package/dist/dkg-agent-cg-on-chain-id.js.map +1 -1
- package/dist/dkg-agent-cg-registry.d.ts +7 -3
- package/dist/dkg-agent-cg-registry.d.ts.map +1 -1
- package/dist/dkg-agent-cg-registry.js +30 -16
- package/dist/dkg-agent-cg-registry.js.map +1 -1
- package/dist/dkg-agent-cg-resolve.d.ts +10 -6
- package/dist/dkg-agent-cg-resolve.d.ts.map +1 -1
- package/dist/dkg-agent-cg-resolve.js +16 -19
- package/dist/dkg-agent-cg-resolve.js.map +1 -1
- package/dist/dkg-agent-context-graph.d.ts.map +1 -1
- package/dist/dkg-agent-context-graph.js +0 -4
- package/dist/dkg-agent-context-graph.js.map +1 -1
- package/dist/dkg-agent-crypto.d.ts.map +1 -1
- package/dist/dkg-agent-crypto.js +5 -4
- package/dist/dkg-agent-crypto.js.map +1 -1
- package/dist/dkg-agent-lifecycle.d.ts +5 -0
- package/dist/dkg-agent-lifecycle.d.ts.map +1 -1
- package/dist/dkg-agent-lifecycle.js +156 -133
- package/dist/dkg-agent-lifecycle.js.map +1 -1
- package/dist/dkg-agent-publish.d.ts.map +1 -1
- package/dist/dkg-agent-publish.js +2 -3
- package/dist/dkg-agent-publish.js.map +1 -1
- package/dist/dkg-agent-query.d.ts.map +1 -1
- package/dist/dkg-agent-query.js +12 -9
- package/dist/dkg-agent-query.js.map +1 -1
- package/dist/dkg-agent-registered-private-empty-vm.d.ts +8 -0
- package/dist/dkg-agent-registered-private-empty-vm.d.ts.map +1 -1
- package/dist/dkg-agent-registered-private-empty-vm.js +15 -0
- package/dist/dkg-agent-registered-private-empty-vm.js.map +1 -1
- package/dist/dkg-agent-rfc64-catalog-auto-publish.d.ts.map +1 -1
- package/dist/dkg-agent-rfc64-catalog-auto-publish.js +4 -0
- package/dist/dkg-agent-rfc64-catalog-auto-publish.js.map +1 -1
- package/dist/dkg-agent-rfc64-catalog-upsert.d.ts.map +1 -1
- package/dist/dkg-agent-rfc64-catalog-upsert.js +7 -0
- package/dist/dkg-agent-rfc64-catalog-upsert.js.map +1 -1
- package/dist/dkg-agent-rfc64-catalog.d.ts +4 -0
- package/dist/dkg-agent-rfc64-catalog.d.ts.map +1 -1
- package/dist/dkg-agent-rfc64-catalog.js +12 -2
- package/dist/dkg-agent-rfc64-catalog.js.map +1 -1
- package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.d.ts +2 -1
- package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.d.ts.map +1 -1
- package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.js +23 -15
- package/dist/dkg-agent-rfc64-swm-catalog-projection-supervisor.js.map +1 -1
- package/dist/dkg-agent-rfc64-swm-catalog-projection.d.ts.map +1 -1
- package/dist/dkg-agent-rfc64-swm-catalog-projection.js +3 -0
- package/dist/dkg-agent-rfc64-swm-catalog-projection.js.map +1 -1
- package/dist/dkg-agent-swm-host.d.ts +13 -22
- package/dist/dkg-agent-swm-host.d.ts.map +1 -1
- package/dist/dkg-agent-swm-host.js +179 -81
- package/dist/dkg-agent-swm-host.js.map +1 -1
- package/dist/dkg-agent-swm-substrate.d.ts +2 -0
- package/dist/dkg-agent-swm-substrate.d.ts.map +1 -1
- package/dist/dkg-agent-swm-substrate.js +5 -9
- package/dist/dkg-agent-swm-substrate.js.map +1 -1
- package/dist/dkg-agent-types.d.ts +3 -2
- package/dist/dkg-agent-types.d.ts.map +1 -1
- package/dist/dkg-agent.d.ts +4 -10
- package/dist/dkg-agent.d.ts.map +1 -1
- package/dist/dkg-agent.js +41 -41
- package/dist/dkg-agent.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.d.ts +6 -1
- package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.d.ts.map +1 -1
- package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.js +5 -5
- package/dist/internal/context-graph-authority/context-graph-agent-gate-authority.js.map +1 -1
- package/dist/internal/context-graph-meta-record-copy.d.ts +1 -1
- package/dist/internal/context-graph-meta-record-copy.d.ts.map +1 -1
- package/dist/internal/context-graph-meta-record.d.ts +40 -0
- package/dist/internal/context-graph-meta-record.d.ts.map +1 -0
- package/dist/internal/context-graph-meta-record.js +3 -0
- package/dist/internal/context-graph-meta-record.js.map +1 -0
- package/dist/internal/peer-gate-revision.d.ts +5 -5
- package/dist/internal/peer-gate-revision.js +5 -5
- package/dist/internal/projection-mutation-observer.d.ts.map +1 -1
- package/dist/internal/projection-mutation-observer.js +5 -23
- package/dist/internal/projection-mutation-observer.js.map +1 -1
- package/dist/internal/recipient-key-route-fence.d.ts.map +1 -1
- package/dist/internal/recipient-key-route-fence.js +30 -18
- package/dist/internal/recipient-key-route-fence.js.map +1 -1
- package/dist/main-thread-time-slice.d.ts +19 -0
- package/dist/main-thread-time-slice.d.ts.map +1 -0
- package/dist/main-thread-time-slice.js +32 -0
- package/dist/main-thread-time-slice.js.map +1 -0
- package/dist/p2p/storage-ack-registrar.d.ts.map +1 -1
- package/dist/p2p/storage-ack-registrar.js +3 -5
- package/dist/p2p/storage-ack-registrar.js.map +1 -1
- package/dist/registered-context-graph-authority.d.ts +11 -0
- package/dist/registered-context-graph-authority.d.ts.map +1 -1
- package/dist/registered-private-empty-vm-attempt-v1.d.ts.map +1 -1
- package/dist/registered-private-empty-vm-attempt-v1.js +8 -4
- package/dist/registered-private-empty-vm-attempt-v1.js.map +1 -1
- package/dist/rfc64/catalog-repair-retry-v1.d.ts +9 -3
- package/dist/rfc64/catalog-repair-retry-v1.d.ts.map +1 -1
- package/dist/rfc64/catalog-repair-retry-v1.js +22 -6
- package/dist/rfc64/catalog-repair-retry-v1.js.map +1 -1
- package/dist/rfc64/control-envelope-signer-v1.d.ts +8 -0
- package/dist/rfc64/control-envelope-signer-v1.d.ts.map +1 -1
- package/dist/rfc64/control-envelope-signer-v1.js +20 -0
- package/dist/rfc64/control-envelope-signer-v1.js.map +1 -1
- package/dist/rfc64/legacy-swm-boundary-fence-v1.d.ts +109 -0
- package/dist/rfc64/legacy-swm-boundary-fence-v1.d.ts.map +1 -0
- package/dist/rfc64/legacy-swm-boundary-fence-v1.js +236 -0
- package/dist/rfc64/legacy-swm-boundary-fence-v1.js.map +1 -0
- package/dist/rfc64/legacy-swm-boundary-v1.d.ts +28 -1
- package/dist/rfc64/legacy-swm-boundary-v1.d.ts.map +1 -1
- package/dist/rfc64/legacy-swm-boundary-v1.js +74 -145
- package/dist/rfc64/legacy-swm-boundary-v1.js.map +1 -1
- package/dist/rfc64/public-catalog-successor-producer-v1.d.ts +2 -0
- package/dist/rfc64/public-catalog-successor-producer-v1.d.ts.map +1 -1
- package/dist/rfc64/public-catalog-successor-producer-v1.js +77 -33
- package/dist/rfc64/public-catalog-successor-producer-v1.js.map +1 -1
- package/dist/rfc64/public-catalog-successor-row-binding-v1.d.ts +16 -0
- package/dist/rfc64/public-catalog-successor-row-binding-v1.d.ts.map +1 -0
- package/dist/rfc64/public-catalog-successor-row-binding-v1.js +28 -0
- package/dist/rfc64/public-catalog-successor-row-binding-v1.js.map +1 -0
- package/dist/rfc64/swm-inventory-catalog-reconciler-v1.d.ts +6 -0
- package/dist/rfc64/swm-inventory-catalog-reconciler-v1.d.ts.map +1 -1
- package/dist/rfc64/swm-inventory-catalog-reconciler-v1.js +9 -3
- package/dist/rfc64/swm-inventory-catalog-reconciler-v1.js.map +1 -1
- package/dist/rfc64/swm-inventory-settlement-outlook-v1.d.ts +8 -0
- package/dist/rfc64/swm-inventory-settlement-outlook-v1.d.ts.map +1 -0
- package/dist/rfc64/swm-inventory-settlement-outlook-v1.js +32 -0
- package/dist/rfc64/swm-inventory-settlement-outlook-v1.js.map +1 -0
- package/dist/sync/requester/swm-recovery-apply.d.ts +1 -1
- package/dist/sync/requester/swm-recovery-apply.d.ts.map +1 -1
- package/dist/sync/requester/swm-recovery-apply.js +0 -1
- package/dist/sync/requester/swm-recovery-apply.js.map +1 -1
- package/dist/sync/requester/swm-target-executor.d.ts +2 -2
- package/dist/sync/requester/swm-target-executor.d.ts.map +1 -1
- package/dist/sync/requester/swm-target-executor.js +1 -2
- package/dist/sync/requester/swm-target-executor.js.map +1 -1
- package/package.json +11 -8
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ApprovedPrivateReplicaAuthorityResolution } from './approved-private-replica.js';
|
|
2
|
+
import type { DKGAgent } from './dkg-agent.js';
|
|
3
|
+
/** Runs of the local proof one decision may use: the first and two more. */
|
|
4
|
+
export declare const APPROVED_PRIVATE_REPLICA_PROOF_MAX_RUNS = 3;
|
|
5
|
+
/** Why a run said nothing about the member, so the proof may run again. */
|
|
6
|
+
export type ApprovedPrivateReplicaProofRerunCause = 'metadata-moved' | 'timeout';
|
|
7
|
+
export type ApprovedPrivateReplicaProofOutcome = Readonly<{
|
|
8
|
+
kind: 'proved';
|
|
9
|
+
resolution: ApprovedPrivateReplicaAuthorityResolution;
|
|
10
|
+
}>
|
|
11
|
+
/** A run read unmoved metadata to the end and found no current proof. */
|
|
12
|
+
| Readonly<{
|
|
13
|
+
kind: 'absent';
|
|
14
|
+
}>
|
|
15
|
+
/** Every run was discarded because the graph's metadata moved while it read. */
|
|
16
|
+
| Readonly<{
|
|
17
|
+
kind: 'metadata-moved';
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Run the approved member's local proof for one decision, and run it again
|
|
21
|
+
* where a run said nothing about the member: its time limit ended it, or the
|
|
22
|
+
* graph's metadata revision moved under reads that otherwise all held.
|
|
23
|
+
*
|
|
24
|
+
* Nothing is relaxed. Each run is the complete proof under its own time limit
|
|
25
|
+
* and its own revision fence, the approval is read again before each run, and
|
|
26
|
+
* every run is held to the request generation the first one read. A run that
|
|
27
|
+
* finds anything else (no approval, another generation, a pending registration,
|
|
28
|
+
* a failed read) ends the decision exactly as a single run does: `absent`, or
|
|
29
|
+
* the error it threw. So does the last permitted run, whatever its cause.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveApprovedPrivateReplicaAuthorityWithinRuns(agent: DKGAgent, contextGraphId: string, approvedAgentAddress: string, fences: {
|
|
32
|
+
readonly approvalStillHolds: () => boolean;
|
|
33
|
+
readonly readMetadataRevision: () => string;
|
|
34
|
+
}, options: {
|
|
35
|
+
readonly timeoutMs: number;
|
|
36
|
+
readonly signal?: AbortSignal;
|
|
37
|
+
/** Told before each further run, for the log. */
|
|
38
|
+
readonly onRerun?: (cause: ApprovedPrivateReplicaProofRerunCause, run: number) => void;
|
|
39
|
+
}): Promise<ApprovedPrivateReplicaProofOutcome>;
|
|
40
|
+
//# sourceMappingURL=approved-private-replica-proof-runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approved-private-replica-proof-runs.d.ts","sourceRoot":"","sources":["../src/approved-private-replica-proof-runs.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,yCAAyC,EAC/C,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,4EAA4E;AAC5E,eAAO,MAAM,uCAAuC,IAAI,CAAC;AAEzD,2EAA2E;AAC3E,MAAM,MAAM,qCAAqC,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAEjF,MAAM,MAAM,kCAAkC,GAC1C,QAAQ,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,UAAU,EAAE,yCAAyC,CAAA;CAAE,CAAC;AACrF,yEAAyE;GACvE,QAAQ,CAAC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAC9B,gFAAgF;GAC9E,QAAQ,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,wBAAsB,gDAAgD,CACpE,KAAK,EAAE,QAAQ,EACf,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,MAAM,EAC5B,MAAM,EAAE;IACN,QAAQ,CAAC,kBAAkB,EAAE,MAAM,OAAO,CAAC;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,MAAM,MAAM,CAAC;CAC7C,EACD,OAAO,EAAE;IACP,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,iDAAiD;IACjD,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,qCAAqC,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACxF,GACA,OAAO,CAAC,kCAAkC,CAAC,CAsC7C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { resolveApprovedPrivateReplicaAuthority, } from './approved-private-replica.js';
|
|
3
|
+
import { isBoundedOperationTimeoutError, runBoundedOperation } from './bounded-operation.js';
|
|
4
|
+
/** Runs of the local proof one decision may use: the first and two more. */
|
|
5
|
+
export const APPROVED_PRIVATE_REPLICA_PROOF_MAX_RUNS = 3;
|
|
6
|
+
/**
|
|
7
|
+
* Run the approved member's local proof for one decision, and run it again
|
|
8
|
+
* where a run said nothing about the member: its time limit ended it, or the
|
|
9
|
+
* graph's metadata revision moved under reads that otherwise all held.
|
|
10
|
+
*
|
|
11
|
+
* Nothing is relaxed. Each run is the complete proof under its own time limit
|
|
12
|
+
* and its own revision fence, the approval is read again before each run, and
|
|
13
|
+
* every run is held to the request generation the first one read. A run that
|
|
14
|
+
* finds anything else (no approval, another generation, a pending registration,
|
|
15
|
+
* a failed read) ends the decision exactly as a single run does: `absent`, or
|
|
16
|
+
* the error it threw. So does the last permitted run, whatever its cause.
|
|
17
|
+
*/
|
|
18
|
+
export async function resolveApprovedPrivateReplicaAuthorityWithinRuns(agent, contextGraphId, approvedAgentAddress, fences, options) {
|
|
19
|
+
let requestGeneration;
|
|
20
|
+
const acceptsRequestGeneration = (observed) => ((requestGeneration ??= observed) === observed);
|
|
21
|
+
for (let run = 1;; run += 1) {
|
|
22
|
+
const metadataRevision = fences.readMetadataRevision();
|
|
23
|
+
let metadataMoved = false;
|
|
24
|
+
let timeout;
|
|
25
|
+
try {
|
|
26
|
+
const resolution = await runBoundedOperation((signal) => resolveApprovedPrivateReplicaAuthority(agent, contextGraphId, approvedAgentAddress, fences.approvalStillHolds, () => fences.readMetadataRevision() === metadataRevision, signal, { acceptsRequestGeneration, metadataMoved: () => { metadataMoved = true; } }), {
|
|
27
|
+
label: `resolveApprovedPrivateReplicaAuthority(${contextGraphId})`,
|
|
28
|
+
timeoutMs: options.timeoutMs,
|
|
29
|
+
signal: options.signal,
|
|
30
|
+
});
|
|
31
|
+
if (resolution !== null)
|
|
32
|
+
return { kind: 'proved', resolution };
|
|
33
|
+
if (!metadataMoved)
|
|
34
|
+
return { kind: 'absent' };
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (!isBoundedOperationTimeoutError(error))
|
|
38
|
+
throw error;
|
|
39
|
+
timeout = error;
|
|
40
|
+
}
|
|
41
|
+
if (run >= APPROVED_PRIVATE_REPLICA_PROOF_MAX_RUNS || !fences.approvalStillHolds()) {
|
|
42
|
+
if (timeout !== undefined)
|
|
43
|
+
throw timeout;
|
|
44
|
+
return { kind: 'metadata-moved' };
|
|
45
|
+
}
|
|
46
|
+
options.onRerun?.(timeout === undefined ? 'metadata-moved' : 'timeout', run + 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=approved-private-replica-proof-runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approved-private-replica-proof-runs.js","sourceRoot":"","sources":["../src/approved-private-replica-proof-runs.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EACL,sCAAsC,GAEvC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,8BAA8B,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7F,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uCAAuC,GAAG,CAAC,CAAC;AAYzD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gDAAgD,CACpE,KAAe,EACf,cAAsB,EACtB,oBAA4B,EAC5B,MAGC,EACD,OAKC;IAED,IAAI,iBAAqC,CAAC;IAC1C,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,CAC9D,CAAC,iBAAiB,KAAK,QAAQ,CAAC,KAAK,QAAQ,CAC9C,CAAC;IACF,KAAK,IAAI,GAAG,GAAG,CAAC,GAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,gBAAgB,GAAG,MAAM,CAAC,oBAAoB,EAAE,CAAC;QACvD,IAAI,aAAa,GAAG,KAAK,CAAC;QAC1B,IAAI,OAAgB,CAAC;QACrB,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,MAAM,mBAAmB,CAC1C,CAAC,MAAM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
|
|
46
|
+
/**
|
|
47
|
+
* Hooks for a caller that may run the proof again for the same decision. Both
|
|
48
|
+
* can only take a result away from a run; neither can add one.
|
|
49
|
+
*/
|
|
50
|
+
export interface ApprovedPrivateReplicaProofRun {
|
|
51
|
+
/**
|
|
52
|
+
* Called with the generation of the approved request the run starts from.
|
|
53
|
+
* `false` ends the run without a proof, which is how every run of one
|
|
54
|
+
* decision is held to the generation the first one read.
|
|
55
|
+
*/
|
|
56
|
+
acceptsRequestGeneration(requestGeneration: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Called when a run is discarded for a moved metadata revision and nothing
|
|
59
|
+
* else: every check before that one held.
|
|
60
|
+
*/
|
|
61
|
+
metadataMoved(): void;
|
|
62
|
+
}
|
|
46
63
|
/**
|
|
47
64
|
* Resolve the current authority proved by a durable approved private join.
|
|
48
65
|
*
|
|
@@ -50,5 +67,5 @@ export type ApprovedPrivateReplicaAuthorityResolution = Readonly<{
|
|
|
50
67
|
* source-qualified private roster. Callers must independently establish exact
|
|
51
68
|
* finalized chain-name absence before treating the graph as unregistered.
|
|
52
69
|
*/
|
|
53
|
-
export declare function resolveApprovedPrivateReplicaAuthority(agent: DKGAgent, contextGraphId: string, approvedAgentAddress: string | undefined, approvalStillHolds: () => boolean, metadataStillCurrent: () => boolean, signal?: AbortSignal): Promise<ApprovedPrivateReplicaAuthorityResolution | null>;
|
|
70
|
+
export declare function resolveApprovedPrivateReplicaAuthority(agent: DKGAgent, contextGraphId: string, approvedAgentAddress: string | undefined, approvalStillHolds: () => boolean, metadataStillCurrent: () => boolean, signal?: AbortSignal, run?: ApprovedPrivateReplicaProofRun): Promise<ApprovedPrivateReplicaAuthorityResolution | null>;
|
|
54
71
|
//# sourceMappingURL=approved-private-replica.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approved-private-replica.d.ts","sourceRoot":"","sources":["../src/approved-private-replica.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,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CAAC;IAC5C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;;;;OAMG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CACtD,SAAS,EAAE,+BAA+B,EAC1C,KAAK,SAAa,GACjB,OAAO,CAGT;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,yCAAyC,GACjD,QAAQ,CAAC;IACP,IAAI,EAAE,8BAA8B,CAAC;IACrC,SAAS,EAAE,+BAA+B,CAAC;CAC5C,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,2BAA2B,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,+BAA+B,CAAC;CAC5C,CAAC,CAAC;AAEP;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7D;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;CACvB;AA4BD;;;;;;GAMG;AACH,wBAAsB,sCAAsC,CAC1D,KAAK,EAAE,QAAQ,EACf,cAAc,EAAE,MAAM,EACtB,oBAAoB,EAAE,MAAM,GAAG,SAAS,EACxC,kBAAkB,EAAE,MAAM,OAAO,EACjC,oBAAoB,EAAE,MAAM,OAAO,EACnC,MAAM,CAAC,EAAE,WAAW,EACpB,GAAG,CAAC,EAAE,8BAA8B,GACnC,OAAO,CAAC,yCAAyC,GAAG,IAAI,CAAC,CAiH3D"}
|
|
@@ -48,7 +48,7 @@ function parseRegisteredMetaOnChainId(bindings) {
|
|
|
48
48
|
* source-qualified private roster. Callers must independently establish exact
|
|
49
49
|
* finalized chain-name absence before treating the graph as unregistered.
|
|
50
50
|
*/
|
|
51
|
-
export async function resolveApprovedPrivateReplicaAuthority(agent, contextGraphId, approvedAgentAddress, approvalStillHolds, metadataStillCurrent, signal) {
|
|
51
|
+
export async function resolveApprovedPrivateReplicaAuthority(agent, contextGraphId, approvedAgentAddress, approvalStillHolds, metadataStillCurrent, signal, run) {
|
|
52
52
|
const approved = approvedAgentAddress?.toLowerCase();
|
|
53
53
|
const hasLocalAgent = () => agent.listLocalAgents().some(({ agentAddress }) => agentAddress.toLowerCase() === approved);
|
|
54
54
|
if (!approved || !hasLocalAgent())
|
|
@@ -64,6 +64,8 @@ export async function resolveApprovedPrivateReplicaAuthority(agent, contextGraph
|
|
|
64
64
|
|| !EVM_ADDRESS.test(state.curatorAgentAddress)
|
|
65
65
|
|| state.curatorAgentAddress === ZERO_ADDRESS)
|
|
66
66
|
return null;
|
|
67
|
+
if (run?.acceptsRequestGeneration(state.requestGeneration) === false)
|
|
68
|
+
return null;
|
|
67
69
|
const ownerAddress = state.curatorAgentAddress;
|
|
68
70
|
const meta = await agent.getOwnCgMetaFacts(contextGraphId, { signal });
|
|
69
71
|
const owners = new Set(meta.curators.map((did) => did
|
|
@@ -111,9 +113,13 @@ export async function resolveApprovedPrivateReplicaAuthority(agent, contextGraph
|
|
|
111
113
|
|| current.requestGeneration !== state.requestGeneration
|
|
112
114
|
|| current.curatorPeerId !== state.curatorPeerId
|
|
113
115
|
|| current.curatorAgentAddress !== ownerAddress
|
|
114
|
-
|| current.curatorAuthorityEra !== '0'
|
|
115
|
-
|
|
116
|
+
|| current.curatorAuthorityEra !== '0')
|
|
117
|
+
return null;
|
|
118
|
+
// Checked last, so a run discarded here had every earlier check hold.
|
|
119
|
+
if (!metadataStillCurrent()) {
|
|
120
|
+
run?.metadataMoved();
|
|
116
121
|
return null;
|
|
122
|
+
}
|
|
117
123
|
// The proof query embeds its start time. Recheck the deadline it proved
|
|
118
124
|
// after every await so a delegation cannot expire while the read is in
|
|
119
125
|
// flight and still authorize the replica.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approved-private-replica.js","sourceRoot":"","sources":["../src/approved-private-replica.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EACL,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,6CAA6C,GAC9C,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,YAAY,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;AAwB3C;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CACtD,SAA0C,EAC1C,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE;IAElB,OAAO,SAAS,CAAC,qBAAqB,KAAK,SAAS;WAC/C,sCAAsC,CAAC,SAAS,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;AACtF,CAAC;
|
|
1
|
+
{"version":3,"file":"approved-private-replica.js","sourceRoot":"","sources":["../src/approved-private-replica.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EACL,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,6CAA6C,GAC9C,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,YAAY,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;AAwB3C;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CACtD,SAA0C,EAC1C,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE;IAElB,OAAO,SAAS,CAAC,qBAAqB,KAAK,SAAS;WAC/C,sCAAsC,CAAC,SAAS,CAAC,qBAAqB,E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C;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,8BAA8B;QACpC,SAAS;KACV,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ChainAdapter, ContextGraphOnChain } from '@origintrail-official/dkg-chain';
|
|
2
|
+
/** Automatic discovery may fill a binding, but cannot replace an owned canonical slot. */
|
|
3
|
+
export declare function conflictsWithOwnedContextGraphBinding(currentId: string | undefined, incomingId: string | undefined): boolean;
|
|
2
4
|
export type DiscoveredContextGraphBinding = {
|
|
3
5
|
kind: 'unrevealed';
|
|
4
6
|
registryNameHash: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-graph-chain-discovery-binding.d.ts","sourceRoot":"","sources":["../src/context-graph-chain-discovery-binding.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"context-graph-chain-discovery-binding.d.ts","sourceRoot":"","sources":["../src/context-graph-chain-discovery-binding.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGzF,0FAA0F;AAC1F,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAIT;AAED,MAAM,MAAM,6BAA6B,GACrC;IACA,IAAI,EAAE,YAAY,CAAC;IACnB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,GACC;IACA,IAAI,EAAE,SAAS,CAAC;IAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,GACC;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAEJ;;;;;GAKG;AACH,wBAAsB,oCAAoC,CACxD,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,6BAA6B,CAAC,CAyExC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
+
import { isCanonicalAuthoritativeContextGraphId } from './context-graph-binding-state.js';
|
|
3
|
+
/** Automatic discovery may fill a binding, but cannot replace an owned canonical slot. */
|
|
4
|
+
export function conflictsWithOwnedContextGraphBinding(currentId, incomingId) {
|
|
5
|
+
return isCanonicalAuthoritativeContextGraphId(currentId)
|
|
6
|
+
&& isCanonicalAuthoritativeContextGraphId(incomingId)
|
|
7
|
+
&& currentId !== incomingId;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Normalize the legacy ContextGraphOnChain identifier boundary before any
|
|
4
11
|
* agent-local RDF or subscription mutation. Production EVM enumeration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-graph-chain-discovery-binding.js","sourceRoot":"","sources":["../src/context-graph-chain-discovery-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"context-graph-chain-discovery-binding.js","sourceRoot":"","sources":["../src/context-graph-chain-discovery-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAE1F,0FAA0F;AAC1F,MAAM,UAAU,qCAAqC,CACnD,SAA6B,EAC7B,UAA8B;IAE9B,OAAO,sCAAsC,CAAC,SAAS,CAAC;WACnD,sCAAsC,CAAC,UAAU,CAAC;WAClD,SAAS,KAAK,UAAU,CAAC;AAChC,CAAC;AAoBD;;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SAAS,KAAK,IAAI,IAAI,SAAS,IAAI,EAAE,EAAE,CAAC;YAC1C,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,gBAAgB;gBAChB,gBAAgB,EAAE,KAAK;gBACvB,OAAO,EACL,kCAAkC,KAAK,CAAC,IAAI,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM;oBACrF,uEAAuE;aAC1E,CAAC;QACJ,CAAC;QAED,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE;YAC/B,gBAAgB;SACjB,CAAC;IACJ,CAAC;IAED,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/C,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,SAAS,EAAE,KAAK,CAAC,cAAc;YAC/B,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,KAAK;QACvB,OAAO,EACL,kCAAkC,KAAK,CAAC,IAAI,qCAAqC;YACjF,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ContextGraphSubInput, ContextGraphSubscriptionRecord } from './dkg-agent-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Restore exact saved identity independently of subscription activity. This
|
|
4
|
+
* projection owns no state, authority reads, network effects or persistence.
|
|
5
|
+
* Conflicting/invalid rows cannot select a numeric slot by snapshot order.
|
|
6
|
+
*/
|
|
7
|
+
export declare function projectDormantContextGraphIdentities(rows: readonly ContextGraphSubscriptionRecord[]): ReadonlyMap<string, ContextGraphSubInput>;
|
|
8
|
+
//# sourceMappingURL=context-graph-dormant-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-graph-dormant-identity.d.ts","sourceRoot":"","sources":["../src/context-graph-dormant-identity.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAEjG;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,SAAS,8BAA8B,EAAE,GAC9C,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAuC3C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { isCanonicalAuthoritativeContextGraphId } from './context-graph-binding-state.js';
|
|
4
|
+
/**
|
|
5
|
+
* Restore exact saved identity independently of subscription activity. This
|
|
6
|
+
* projection owns no state, authority reads, network effects or persistence.
|
|
7
|
+
* Conflicting/invalid rows cannot select a numeric slot by snapshot order.
|
|
8
|
+
*/
|
|
9
|
+
export function projectDormantContextGraphIdentities(rows) {
|
|
10
|
+
const projected = new Map();
|
|
11
|
+
for (const row of rows) {
|
|
12
|
+
let identity = null;
|
|
13
|
+
if (isCanonicalAuthoritativeContextGraphId(row.onChainId)) {
|
|
14
|
+
try {
|
|
15
|
+
const commitment = ethers.keccak256(ethers.toUtf8Bytes(row.id)).toLowerCase();
|
|
16
|
+
const explicitHash = row.onChainHash?.toLowerCase();
|
|
17
|
+
const hashShaped = /^0x[0-9a-f]{64}$/i.test(row.id);
|
|
18
|
+
const wirePlaceholder = hashShaped && explicitHash === row.id.toLowerCase();
|
|
19
|
+
// A legacy hash-keyed row without its hash is ambiguous. Leave it for
|
|
20
|
+
// matching native chain observation to stage/repair rather than invent
|
|
21
|
+
// the commitment of a possible placeholder's literal spelling.
|
|
22
|
+
if ((explicitHash === undefined && !hashShaped) || explicitHash === commitment || wirePlaceholder) {
|
|
23
|
+
identity = {
|
|
24
|
+
name: row.name,
|
|
25
|
+
onChainId: row.onChainId,
|
|
26
|
+
onChainHash: explicitHash ?? commitment,
|
|
27
|
+
syncMode: 'always-on',
|
|
28
|
+
subscribed: false, coreHosted: false, synced: false,
|
|
29
|
+
sharedMemorySynced: false, metaSynced: false,
|
|
30
|
+
lastReconciledOrdinal: row.lastReconciledOrdinal,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// Invalid UTF-16 cannot establish a committed local graph identity.
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const previous = projected.get(row.id);
|
|
39
|
+
if (projected.has(row.id) && (previous === null || identity === null
|
|
40
|
+
|| previous?.onChainId !== identity.onChainId
|
|
41
|
+
|| previous?.onChainHash !== identity.onChainHash))
|
|
42
|
+
projected.set(row.id, null);
|
|
43
|
+
else
|
|
44
|
+
projected.set(row.id, identity);
|
|
45
|
+
}
|
|
46
|
+
return new Map([...projected].filter((entry) => entry[1] !== null));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=context-graph-dormant-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-graph-dormant-identity.js","sourceRoot":"","sources":["../src/context-graph-dormant-identity.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,sCAAsC,EAAE,MAAM,kCAAkC,CAAC;AAG1F;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAClD,IAA+C;IAE/C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAuC,CAAC;IACjE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,QAAQ,GAAgC,IAAI,CAAC;QACjD,IAAI,sCAAsC,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1D,IAAI,CAAC;gBACH,MAAM,UAA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;YAAE,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;;YAC1B,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,CAClC,CAAC,KAAK,EAA2C,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CACtE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,45 +1,9 @@
|
|
|
1
1
|
import type { Quad, QueryOptions, TripleStore } from '@origintrail-official/dkg-storage';
|
|
2
|
+
import type { StoreMutation } from './internal/store-mutation.js';
|
|
2
3
|
import { PeerGateRevision } from './internal/peer-gate-revision.js';
|
|
3
4
|
import { RecipientKeyRouteFence } from './internal/recipient-key-route-fence.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
name: string;
|
|
7
|
-
createdBy: string;
|
|
8
|
-
createdAt?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ContextGraphDelegationMeta {
|
|
12
|
-
uri: string;
|
|
13
|
-
agents: string[];
|
|
14
|
-
allowedPeers: string[];
|
|
15
|
-
allowedKeys: string[];
|
|
16
|
-
expiresAtValues: string[];
|
|
17
|
-
}
|
|
18
|
-
export interface ContextGraphMetaRecord {
|
|
19
|
-
id: string;
|
|
20
|
-
uri: string;
|
|
21
|
-
declared: boolean;
|
|
22
|
-
isSystem: boolean;
|
|
23
|
-
name?: string;
|
|
24
|
-
description?: string;
|
|
25
|
-
creator?: string;
|
|
26
|
-
creators: string[];
|
|
27
|
-
curator?: string;
|
|
28
|
-
curators: string[];
|
|
29
|
-
accessPolicy?: string;
|
|
30
|
-
createdAt?: string;
|
|
31
|
-
allowedPeers: string[];
|
|
32
|
-
allowedAgents: string[];
|
|
33
|
-
participantAgents: string[];
|
|
34
|
-
participantIdentityIds: string[];
|
|
35
|
-
revokedAgents: string[];
|
|
36
|
-
delegations: ContextGraphDelegationMeta[];
|
|
37
|
-
onChainId?: string;
|
|
38
|
-
subGraphs: ContextGraphSubGraphMeta[];
|
|
39
|
-
hasAgentGate: boolean;
|
|
40
|
-
hasPeerGate: boolean;
|
|
41
|
-
hasLegacyParticipantGate: boolean;
|
|
42
|
-
}
|
|
5
|
+
import type { ContextGraphMetaRecord } from './internal/context-graph-meta-record.js';
|
|
6
|
+
export type { ContextGraphMetaRecord, ContextGraphSubGraphMeta, ContextGraphDelegationMeta } from './internal/context-graph-meta-record.js';
|
|
43
7
|
export interface ContextGraphReadAuthorityFactsSnapshot {
|
|
44
8
|
/** True only while no projection source has changed since capture began. */
|
|
45
9
|
assertCurrent(): boolean;
|
|
@@ -54,6 +18,12 @@ export declare class ContextGraphMetaProjection {
|
|
|
54
18
|
/** What a recipient resolution depends on: key and route facts, and each graph's peer allowlist (GH#3067). */
|
|
55
19
|
readonly recipientKeyRouteFence: RecipientKeyRouteFence;
|
|
56
20
|
readonly peerGateRevision: PeerGateRevision;
|
|
21
|
+
/** Historical callbacks remain bound and also notify the recipient fence. */
|
|
22
|
+
readonly markDirtyForGraph: (graph: string, subject?: string, predicate?: string) => void;
|
|
23
|
+
readonly markAllDirty: () => void;
|
|
24
|
+
readonly markDirtyFromQuads: (quads: readonly Quad[]) => string[];
|
|
25
|
+
/** Projection-only dispatch: the observed store owns recipient-fence settlement. */
|
|
26
|
+
readonly invalidateStoreMutation: (mutation: StoreMutation) => void;
|
|
57
27
|
constructor(store: TripleStore);
|
|
58
28
|
/** Invalidate request-local absence proofs when projection sources change. */
|
|
59
29
|
get readAuthorityFactsRevision(): number;
|
|
@@ -80,17 +50,10 @@ export declare class ContextGraphMetaProjection {
|
|
|
80
50
|
* authority-facts revision advances. Supersedes a rebuild in flight.
|
|
81
51
|
*/
|
|
82
52
|
requireFreshRead(contextGraphId: string): void;
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
* mutation (e.g. `replaceSubject`) targets, derived from the GRAPH itself, not
|
|
86
|
-
* from the inserted quads, so a delete is covered too. Shared AGENTS/ONTOLOGY
|
|
87
|
-
* sources invalidate every record. Other graphs dirty no cache entry but still
|
|
88
|
-
* advance the authority revision, because key lookup scans all named graphs.
|
|
89
|
-
* The recipient fences are told what the mutation names. */
|
|
90
|
-
markDirtyForGraph(graphUri: string, subject?: string, predicate?: string): void;
|
|
91
|
-
markAllDirty(): void;
|
|
53
|
+
/** Destructive graph mutations invalidate their target cache and request-local revisions. */
|
|
54
|
+
private invalidateGraph;
|
|
92
55
|
private dirtyAll;
|
|
93
|
-
|
|
56
|
+
private invalidateQuads;
|
|
94
57
|
listDeclaredContextGraphIds(options?: QueryOptions): Promise<string[]>;
|
|
95
58
|
private listRootMetaDeclaredContextGraphIds;
|
|
96
59
|
private listCatalogDeclaredContextGraphIds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-graph-meta-projection.d.ts","sourceRoot":"","sources":["../src/context-graph-meta-projection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-graph-meta-projection.d.ts","sourceRoot":"","sources":["../src/context-graph-meta-projection.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAIzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,OAAO,KAAK,EAAE,sBAAsB,EAAwD,MAAM,yCAAyC,CAAC;AAC5I,YAAY,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAS5I,MAAM,WAAW,sCAAsC;IACrD,4EAA4E;IAC5E,aAAa,IAAI,OAAO,CAAC;IACzB,kFAAkF;IAClF,QA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/D;;;;OAIG;IACH,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAK9C,6FAA6F;IAC7F,OAAO,CAAC,eAAe;IAyBvB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,eAAe;IAoBjB,2BAA2B,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YAsClE,mCAAmC;YA+BnC,kCAAkC;YA4BlC,kBAAkB;IAKhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,eAAe,CACnB,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,sBAAsB,CAAC;YAWpB,OAAO;YAqCP,eAAe;YAwDf,qBAAqB;IA4BnC,OAAO,CAAC,SAAS;YA+DH,aAAa;IA4C3B,OAAO,CAAC,2BAA2B;CA+CpC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { DKG_ONTOLOGY, SYSTEM_CONTEXT_GRAPHS, assertSafeIri, contextGraphCatalogUri, contextGraphDataGraphUri, contextGraphDataUri, contextGraphMetaGraphUri, } from '@origintrail-official/dkg-core';
|
|
2
|
+
import { DKG_ONTOLOGY, SYSTEM_CONTEXT_GRAPHS, assertSafeIri, isSafeIri, contextGraphCatalogUri, contextGraphDataGraphUri, contextGraphDataUri, contextGraphMetaGraphUri, } from '@origintrail-official/dkg-core';
|
|
3
|
+
import { WORKSPACE_RECIPIENT_AUTHORITY_PREDICATES as RECIPIENT_AUTHORITY_PREDICATES } from '@origintrail-official/dkg-publisher';
|
|
3
4
|
import { strip, stripLiteral } from './dkg-agent-utils.js';
|
|
4
5
|
import { mapWithConcurrency } from './map-with-concurrency.js';
|
|
5
6
|
import { cloneMetaRecord } from './internal/context-graph-meta-record-copy.js';
|
|
6
7
|
import { PeerGateRevision } from './internal/peer-gate-revision.js';
|
|
7
|
-
import {
|
|
8
|
+
import { RecipientKeyRouteFence } from './internal/recipient-key-route-fence.js';
|
|
8
9
|
const DKG_NS = 'https://dkg.network/ontology#';
|
|
9
10
|
const LEGACY_DKG_NS = 'http://dkg.io/ontology/';
|
|
10
11
|
const LEGACY_SCHEMA_NS = 'http://schema.org/';
|
|
@@ -37,13 +38,7 @@ const DIRECT_META_PREDICATES = new Set([
|
|
|
37
38
|
]);
|
|
38
39
|
// Recipient resolution scans these facts across every named graph. They do not
|
|
39
40
|
// populate ContextGraphMetaRecord, but they can change a recipient set.
|
|
40
|
-
const WORKSPACE_RECIPIENT_AUTHORITY_PREDICATES = new Set(
|
|
41
|
-
DKG_ONTOLOGY.DKG_ACCESS_POLICY,
|
|
42
|
-
DKG_ONTOLOGY.DKG_ALLOWED_AGENT,
|
|
43
|
-
DKG_ONTOLOGY.DKG_PARTICIPANT_AGENT,
|
|
44
|
-
DKG_ONTOLOGY.DKG_REVOKED_AGENT,
|
|
45
|
-
...RECIPIENT_KEY_ROUTE_PREDICATES,
|
|
46
|
-
]);
|
|
41
|
+
const WORKSPACE_RECIPIENT_AUTHORITY_PREDICATES = new Set(RECIPIENT_AUTHORITY_PREDICATES);
|
|
47
42
|
const SUB_GRAPH_META_PREDICATES = new Set([
|
|
48
43
|
DKG_ONTOLOGY.RDF_TYPE,
|
|
49
44
|
DKG_ONTOLOGY.SCHEMA_NAME,
|
|
@@ -80,6 +75,9 @@ const CATALOG_META_PREDICATES = new Set([
|
|
|
80
75
|
const PROJECTION_RECORD_PREDICATES = new Set([
|
|
81
76
|
...DIRECT_META_PREDICATES, ...SUB_GRAPH_META_PREDICATES, ...DELEGATION_META_PREDICATES, ...CATALOG_META_PREDICATES
|
|
82
77
|
]);
|
|
78
|
+
const AGENT_ROSTER_PREDICATES = new Set([
|
|
79
|
+
DKG_ONTOLOGY.DKG_ALLOWED_AGENT, DKG_ONTOLOGY.DKG_PARTICIPANT_AGENT, DKG_ONTOLOGY.DKG_REVOKED_AGENT
|
|
80
|
+
]);
|
|
83
81
|
/**
|
|
84
82
|
* A `ContextGraphMetaRecord` with no facts loaded yet.
|
|
85
83
|
*
|
|
@@ -115,6 +113,46 @@ export class ContextGraphMetaProjection {
|
|
|
115
113
|
/** What a recipient resolution depends on: key and route facts, and each graph's peer allowlist (GH#3067). */
|
|
116
114
|
recipientKeyRouteFence;
|
|
117
115
|
peerGateRevision = new PeerGateRevision(PROJECTION_RECORD_PREDICATES);
|
|
116
|
+
/** Historical callbacks remain bound and also notify the recipient fence. */
|
|
117
|
+
markDirtyForGraph = (graph, subject, predicate) => {
|
|
118
|
+
try {
|
|
119
|
+
this.invalidateGraph(graph, subject, predicate);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
this.recipientKeyRouteFence.noteRemoval({ graph, subject, predicate });
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
markAllDirty = () => {
|
|
126
|
+
try {
|
|
127
|
+
this.dirtyAll();
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
this.recipientKeyRouteFence.noteUnscopedWrite();
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
markDirtyFromQuads = (quads) => {
|
|
134
|
+
try {
|
|
135
|
+
return this.invalidateQuads(quads);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this.recipientKeyRouteFence.noteQuads(quads);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/** Projection-only dispatch: the observed store owns recipient-fence settlement. */
|
|
142
|
+
invalidateStoreMutation = (mutation) => {
|
|
143
|
+
if (mutation.everything || mutation.quads?.some((quad) => !isSafeIri(quad.predicate))) {
|
|
144
|
+
this.dirtyAll();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
for (const { graph, subject, predicate } of mutation.removals ?? []) {
|
|
148
|
+
if (graph === undefined || !isSafeIri(graph))
|
|
149
|
+
this.dirtyAll();
|
|
150
|
+
else
|
|
151
|
+
this.invalidateGraph(graph, subject, predicate);
|
|
152
|
+
}
|
|
153
|
+
if (mutation.quads)
|
|
154
|
+
this.invalidateQuads(mutation.quads);
|
|
155
|
+
};
|
|
118
156
|
constructor(store) {
|
|
119
157
|
this.store = store;
|
|
120
158
|
this.recipientKeyRouteFence = new RecipientKeyRouteFence(store);
|
|
@@ -249,15 +287,8 @@ export class ContextGraphMetaProjection {
|
|
|
249
287
|
if (existing)
|
|
250
288
|
existing.dirty = true;
|
|
251
289
|
}
|
|
252
|
-
/**
|
|
253
|
-
|
|
254
|
-
* mutation (e.g. `replaceSubject`) targets, derived from the GRAPH itself, not
|
|
255
|
-
* from the inserted quads, so a delete is covered too. Shared AGENTS/ONTOLOGY
|
|
256
|
-
* sources invalidate every record. Other graphs dirty no cache entry but still
|
|
257
|
-
* advance the authority revision, because key lookup scans all named graphs.
|
|
258
|
-
* The recipient fences are told what the mutation names. */
|
|
259
|
-
markDirtyForGraph(graphUri, subject, predicate) {
|
|
260
|
-
this.recipientKeyRouteFence.noteRemoval({ graph: graphUri, subject, predicate });
|
|
290
|
+
/** Destructive graph mutations invalidate their target cache and request-local revisions. */
|
|
291
|
+
invalidateGraph(graphUri, subject, predicate) {
|
|
261
292
|
const graph = stripTerm(graphUri);
|
|
262
293
|
if (graph === contextGraphDataGraphUri(SYSTEM_CONTEXT_GRAPHS.AGENTS)
|
|
263
294
|
|| graph === contextGraphDataGraphUri(SYSTEM_CONTEXT_GRAPHS.ONTOLOGY)) {
|
|
@@ -278,10 +309,6 @@ export class ContextGraphMetaProjection {
|
|
|
278
309
|
// non-CG graph advances the request-local fence without dirtying a cache entry.
|
|
279
310
|
this.authorityFactsRevision += 1;
|
|
280
311
|
}
|
|
281
|
-
markAllDirty() {
|
|
282
|
-
this.dirtyAll();
|
|
283
|
-
this.recipientKeyRouteFence.noteUnscopedWrite();
|
|
284
|
-
}
|
|
285
312
|
dirtyAll() {
|
|
286
313
|
this.peerGateRevision.noteEverything();
|
|
287
314
|
this.authorityFactsRevision += 1;
|
|
@@ -291,7 +318,7 @@ export class ContextGraphMetaProjection {
|
|
|
291
318
|
entry.invalidationVersion += 1;
|
|
292
319
|
}
|
|
293
320
|
}
|
|
294
|
-
|
|
321
|
+
invalidateQuads(quads) {
|
|
295
322
|
const touched = new Set();
|
|
296
323
|
let recipientAuthorityTouched = false;
|
|
297
324
|
for (const quad of quads) {
|
|
@@ -306,9 +333,11 @@ export class ContextGraphMetaProjection {
|
|
|
306
333
|
}
|
|
307
334
|
// Generic update and complete-graph replace paths call markAllDirty(); one
|
|
308
335
|
// conservative bump here closes the recipient-key insertion race.
|
|
309
|
-
this.recipientKeyRouteFence.noteQuads(quads);
|
|
310
336
|
if (recipientAuthorityTouched)
|
|
311
337
|
this.authorityFactsRevision += 1;
|
|
338
|
+
// The loop marks only the context graph a quad names; such a fact may be any graph's.
|
|
339
|
+
if (quads.some(mayChangeUnnamedRoster))
|
|
340
|
+
this.dirtyAll();
|
|
312
341
|
return [...touched];
|
|
313
342
|
}
|
|
314
343
|
async listDeclaredContextGraphIds(options = {}) {
|
|
@@ -738,6 +767,24 @@ function applyAccessPolicy(record, value) {
|
|
|
738
767
|
}
|
|
739
768
|
record.accessPolicy ??= value;
|
|
740
769
|
}
|
|
770
|
+
/**
|
|
771
|
+
* A roster fact, written or removed by value, whose context graph its terms do
|
|
772
|
+
* not prove. Only a plain IRI is stored as written: an adapter matches a blank
|
|
773
|
+
* node in a delete against any subject, and drops unsafe characters from a
|
|
774
|
+
* graph name. A plainly named graph that is not a metadata source is harmless,
|
|
775
|
+
* because no record reads a roster from it.
|
|
776
|
+
*/
|
|
777
|
+
function mayChangeUnnamedRoster(quad) {
|
|
778
|
+
if (!AGENT_ROSTER_PREDICATES.has(strip(quad.predicate)))
|
|
779
|
+
return false;
|
|
780
|
+
if (!isSafeIri(quad.graph))
|
|
781
|
+
return true;
|
|
782
|
+
if (isSafeIri(quad.subject))
|
|
783
|
+
return false;
|
|
784
|
+
return contextGraphIdFromMetaGraphUri(quad.graph) !== null
|
|
785
|
+
|| quad.graph === contextGraphDataGraphUri(SYSTEM_CONTEXT_GRAPHS.AGENTS)
|
|
786
|
+
|| quad.graph === contextGraphDataGraphUri(SYSTEM_CONTEXT_GRAPHS.ONTOLOGY);
|
|
787
|
+
}
|
|
741
788
|
function contextGraphIdFromContextGraphUri(uri) {
|
|
742
789
|
if (!uri.startsWith(CONTEXT_GRAPH_PREFIX))
|
|
743
790
|
return null;
|