reploid 0.0.0-stage → 0.1.0
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/apps/poolday/config/chat-files.json +27 -0
- package/apps/poolday/config/partition-generation.js +21 -0
- package/apps/poolday/config/partition-policy.json +74 -0
- package/apps/poolday/config/partition-releases.json +3 -0
- package/apps/poolday/config/work-profile.json +122 -0
- package/apps/poolday/host/chat-view.js +47 -0
- package/apps/poolday/host/earning/client.js +199 -0
- package/apps/poolday/host/earning/contribution.js +168 -0
- package/apps/poolday/host/partition-release.js +33 -0
- package/apps/poolday/host/work-partition-artifact-source.js +37 -0
- package/apps/poolday/host/work-partition-capsule.js +39 -0
- package/apps/poolday/host/work-partition-plan.js +167 -0
- package/apps/poolday/host/work-partition-tokenizer-guard.js +21 -0
- package/apps/poolday/infrastructure/model-storage-lock.js +22 -0
- package/apps/poolday/infrastructure/pack-release-storage.js +52 -0
- package/apps/poolday/pool/pack-operation.js +161 -0
- package/apps/poolday/pool/pack-release-policy.js +44 -0
- package/apps/poolday/pool/peer-pack-data-channel.js +217 -0
- package/apps/poolday/providers/work-adapter.js +67 -0
- package/apps/poolday/providers/work-device.js +33 -0
- package/apps/poolday/providers/work-generation-completion.js +55 -0
- package/apps/poolday/providers/work-provider.js +209 -0
- package/apps/poolday/providers/work-resident-provider.js +113 -0
- package/deploy/artifacts/doppler-gpu-0.7.1.tgz +0 -0
- package/docs/fleet-service.md +214 -0
- package/docs/native-participant.md +534 -0
- package/native-delivery.json +1174 -0
- package/package.json +29 -4
- package/packages/reploid/src/artifacts/binary.js +25 -0
- package/packages/reploid/src/artifacts/canonical-json.js +23 -0
- package/packages/reploid/src/artifacts/custody/exchange.js +402 -0
- package/packages/reploid/src/artifacts/custody/piece-acquisition.js +70 -0
- package/packages/reploid/src/artifacts/custody/runtime.js +404 -0
- package/packages/reploid/src/artifacts/custody/supply-budget.js +19 -0
- package/packages/reploid/src/artifacts/custody-certificate.js +123 -0
- package/packages/reploid/src/artifacts/delivery-attestation.js +64 -0
- package/packages/reploid/src/artifacts/generation-terminal.js +36 -0
- package/packages/reploid/src/artifacts/identity.js +91 -0
- package/packages/reploid/src/artifacts/participant-proofs.js +159 -0
- package/packages/reploid/src/artifacts/receipt.js +131 -0
- package/packages/reploid/src/artifacts/signatures.js +94 -0
- package/packages/reploid/src/artifacts/whole-model-receipt.js +42 -0
- package/packages/reploid/src/cancellation.js +44 -0
- package/packages/reploid/src/config/defaults.json +110 -0
- package/packages/reploid/src/config/index.js +209 -0
- package/packages/reploid/src/config/request-overrides.json +9 -0
- package/packages/reploid/src/config/transport-defaults.json +7 -0
- package/packages/reploid/src/hashing.js +30 -0
- package/packages/reploid/src/measurement/capacity-utilization.js +321 -0
- package/packages/reploid/src/measurement/index.js +5 -0
- package/packages/reploid/src/measurement/readiness-records.js +310 -0
- package/packages/reploid/src/mesh/computer-identity.js +50 -0
- package/packages/reploid/src/mesh/computer-identity.policy.json +8 -0
- package/packages/reploid/src/mesh/contribution.js +141 -0
- package/packages/reploid/src/mesh/generation-recovery.js +58 -0
- package/packages/reploid/src/mesh/gpu-signature-shader.js +27 -0
- package/packages/reploid/src/mesh/gpu-signature.js +136 -0
- package/packages/reploid/src/mesh/gpu-signature.policy.json +11 -0
- package/packages/reploid/src/mesh/index.js +66 -0
- package/packages/reploid/src/mesh/partitions/automatic-ordered-partitions.js +540 -0
- package/packages/reploid/src/mesh/partitions/automatic-partitions.js +298 -0
- package/packages/reploid/src/mesh/partitions/partition-attempt-evidence.js +282 -0
- package/packages/reploid/src/mesh/partitions/partition-attempt-queue-policy.json +6 -0
- package/packages/reploid/src/mesh/partitions/partition-attempt-queue.js +112 -0
- package/packages/reploid/src/mesh/partitions/partition-canonical-contract.js +167 -0
- package/packages/reploid/src/mesh/partitions/partition-canonical-execution.js +168 -0
- package/packages/reploid/src/mesh/partitions/partition-chat-canonical.js +49 -0
- package/packages/reploid/src/mesh/partitions/partition-chat.js +125 -0
- package/packages/reploid/src/mesh/partitions/partition-contract.js +192 -0
- package/packages/reploid/src/mesh/partitions/partition-device-admission.js +96 -0
- package/packages/reploid/src/mesh/partitions/partition-discovery.js +96 -0
- package/packages/reploid/src/mesh/partitions/partition-entry-publication.js +183 -0
- package/packages/reploid/src/mesh/partitions/partition-entry.js +434 -0
- package/packages/reploid/src/mesh/partitions/partition-generation-request.js +33 -0
- package/packages/reploid/src/mesh/partitions/partition-grants.js +277 -0
- package/packages/reploid/src/mesh/partitions/partition-link.js +103 -0
- package/packages/reploid/src/mesh/partitions/partition-network.js +109 -0
- package/packages/reploid/src/mesh/partitions/partition-ordered-chat.js +290 -0
- package/packages/reploid/src/mesh/partitions/partition-ordered-peer.js +415 -0
- package/packages/reploid/src/mesh/partitions/partition-ordered-publication.js +100 -0
- package/packages/reploid/src/mesh/partitions/partition-peer.js +314 -0
- package/packages/reploid/src/mesh/partitions/partition-placement.js +143 -0
- package/packages/reploid/src/mesh/partitions/partition-preparation-progress.js +25 -0
- package/packages/reploid/src/mesh/partitions/partition-receiver-policy.json +7 -0
- package/packages/reploid/src/mesh/partitions/partition-reservations.js +75 -0
- package/packages/reploid/src/mesh/partitions/partition-route-envelope-policy.json +16 -0
- package/packages/reploid/src/mesh/partitions/partition-route-envelope.js +74 -0
- package/packages/reploid/src/mesh/partitions/partition-route-execution.js +409 -0
- package/packages/reploid/src/mesh/partitions/partition-route-network.js +179 -0
- package/packages/reploid/src/mesh/partitions/partition-route-ranking.js +268 -0
- package/packages/reploid/src/mesh/partitions/partition-runner.js +319 -0
- package/packages/reploid/src/mesh/partitions/partition-stage-assignment.js +109 -0
- package/packages/reploid/src/mesh/partitions/partition-stage-commit.js +103 -0
- package/packages/reploid/src/mesh/partitions/partition-step-receiver.js +291 -0
- package/packages/reploid/src/mesh/partitions/partition-summary.js +122 -0
- package/packages/reploid/src/mesh/partitions/preparation-owner.js +40 -0
- package/packages/reploid/src/mesh/partitions/resident-error-codes.json +10 -0
- package/packages/reploid/src/mesh/partitions/resident-partition.js +333 -0
- package/packages/reploid/src/mesh/partitions/resident-route.js +46 -0
- package/packages/reploid/src/mesh/partitions/signed-resident-factory.js +59 -0
- package/packages/reploid/src/mesh/peer-generation.js +896 -0
- package/packages/reploid/src/mesh/peer-identity.js +87 -0
- package/packages/reploid/src/mesh/placement-beliefs.js +107 -0
- package/packages/reploid/src/mesh/preparation-progress.js +46 -0
- package/packages/reploid/src/mesh/provider-hardware.js +11 -0
- package/packages/reploid/src/mesh/remote-generation-requests.js +53 -0
- package/packages/reploid/src/mesh/swarm-coordination.js +140 -0
- package/packages/reploid/src/mesh/web-access-network.js +112 -0
- package/packages/reploid/src/mesh/web-access-policy.json +17 -0
- package/packages/reploid/src/retrieval/citations.js +156 -0
- package/packages/reploid/src/retrieval/claim-support.js +113 -0
- package/packages/reploid/src/retrieval/costs.js +101 -0
- package/packages/reploid/src/retrieval/fixed-provider.js +34 -0
- package/packages/reploid/src/retrieval/index.js +20 -0
- package/packages/reploid/src/retrieval/lexical-support.js +27 -0
- package/packages/reploid/src/retrieval/model-reviewer.js +67 -0
- package/packages/reploid/src/retrieval/page-fetch.json +10 -0
- package/packages/reploid/src/retrieval/page-text.js +182 -0
- package/packages/reploid/src/retrieval/passage.js +37 -0
- package/packages/reploid/src/retrieval/policy.json +14 -0
- package/packages/reploid/src/retrieval/retrieval.js +23 -0
- package/packages/reploid/src/retrieval/review-queue.js +76 -0
- package/packages/reploid/src/retrieval/sources.js +263 -0
- package/packages/reploid/src/retrieval/support-review.js +155 -0
- package/packages/reploid/src/retrieval/text.js +21 -0
- package/packages/reploid/src/rules/contribution.rules.json +8 -0
- package/packages/reploid/src/rules/routing.rules.json +24 -0
- package/packages/reploid/src/transport/assignment.js +571 -0
- package/packages/reploid/src/transport/bounded-channel-writer.js +46 -0
- package/packages/reploid/src/transport/index.js +11 -0
- package/packages/reploid/src/transport/introduction-admission.js +24 -0
- package/packages/reploid/src/transport/introduction-bootstrap.js +112 -0
- package/packages/reploid/src/transport/introduction-policy.json +12 -0
- package/packages/reploid/src/transport/introduction-records.js +90 -0
- package/packages/reploid/src/transport/introductions.js +209 -0
- package/packages/reploid/src/transport/partition-data-channel.js +421 -0
- package/packages/reploid/src/transport/partition-errors.json +16 -0
- package/packages/reploid/src/transport/retry-policy.js +36 -0
- package/packages/reploid/src/transport/room.js +502 -0
- package/packages/reploid/src/transport/sdp-fingerprint.js +5 -0
- package/packages/reploid/src/transport/signaling.js +571 -0
- package/packages/reploid/src/transport/swarm.js +1247 -0
- package/packages/reploid/src/transport/tool-offer-channel.js +137 -0
- package/server/browser-roots.js +42 -0
- package/server/browser-web-worker.js +94 -0
- package/server/chat-completions.js +45 -0
- package/server/fleet/browser-bridge.js +145 -0
- package/server/fleet/contract.js +42 -0
- package/server/fleet/credit-evidence.js +103 -0
- package/server/fleet/credit-recovery.js +175 -0
- package/server/fleet/credits.js +178 -0
- package/server/fleet/execution-admission.js +32 -0
- package/server/fleet/native-host.js +817 -0
- package/server/fleet/placement.js +132 -0
- package/server/fleet/requester.js +346 -0
- package/server/fleet/service.js +311 -0
- package/server/fleet/terminal-policy.js +83 -0
- package/server/fleet/text-api.js +94 -0
- package/server/hashing.js +35 -0
- package/server/http-request-owner.js +49 -0
- package/server/messages.js +57 -0
- package/server/native-canonical-epochs.js +90 -0
- package/server/native-change-log.js +40 -0
- package/server/native-earning.js +203 -0
- package/server/native-generation-journal.js +46 -0
- package/server/native-model-config.js +57 -0
- package/server/native-model-files.js +382 -0
- package/server/native-model-origin.js +54 -0
- package/server/native-model-origins.json +12 -0
- package/server/native-node.js +83 -0
- package/server/native-owner/controls.js +162 -0
- package/server/native-owner/monitor.js +251 -0
- package/server/native-owner/policy.js +273 -0
- package/server/native-owner/rate.js +92 -0
- package/server/native-participant.js +866 -0
- package/server/native-readiness-log.js +30 -0
- package/server/native-release-storage.js +64 -0
- package/server/native-shader-cache.js +369 -0
- package/server/native-supply-budget.js +66 -0
- package/server/native-whole-earning.js +67 -0
- package/server/native-whole-model-fill.js +182 -0
- package/server/native-whole-model.js +130 -0
- package/server/public-web-worker.js +66 -0
- package/server/responses.js +92 -0
- package/server/search/errors.js +47 -0
- package/server/search/page-fetch.js +185 -0
- package/server/text-api.js +83 -0
- package/server/text-recovery.js +45 -0
- package/server/text-request-options.js +23 -0
- package/server/text-requester.js +231 -0
- package/server/token-auth.js +9 -0
- package/server/whole-model-requester.js +99 -0
- package/shared/config/chat-models.json +4685 -0
- package/shared/config/doppler-execution-contracts.js +32 -0
- package/shared/config/doppler-execution-contracts.json +43 -0
- package/shared/config/doppler-generation-contract.js +223 -0
- package/shared/config/doppler-local-models.js +79 -0
- package/shared/config/doppler-package.json +7 -0
- package/shared/config/model-manifests/a0dc69e917133a82780823d17fc771c0f6b882d7c86c571deeaef45be2ff108b.json +6434 -0
- package/shared/config/model-manifests/e985e3cdad60d0cb57d84b436161e66ab5b3f6589a168de6f00b4610e5f1fb59.json +16534 -0
- package/shared/config/model-manifests/fa6eb7bbc3ba63571f8cede780b877d9272bde948697af93dd3d33837cb46137.json +7175 -0
- package/shared/config/model-pieces/qwen-0-8b-pieces.json +1506 -0
- package/shared/config/model-pieces/qwen-2b-pieces.json +4800 -0
- package/shared/config/model-pieces/qwen35b-q4_0-pieces.json +28880 -0
- package/shared/config/reploid-library.json +49 -0
- package/shared/config/swarm-bootstrap.json +21 -0
- package/shared/infrastructure/doppler-runtime-service.js +261 -0
- package/shared/pool/executable-pack.js +87 -0
- package/shared/pool/pack-operation-adapters.js +124 -0
- package/shared/pool/pack-operation-policy.js +75 -0
- package/shared/pool/pool-config.json +2280 -0
- package/shared/vendor/reploid/adapters/doppler-session.js +372 -0
- package/shared/vendor/reploid/artifacts/binary.js +25 -0
- package/shared/vendor/reploid/artifacts/canonical-json.js +23 -0
- package/shared/vendor/reploid/artifacts/delivery-attestation.js +64 -0
- package/shared/vendor/reploid/artifacts/identity.js +91 -0
- package/shared/vendor/reploid/artifacts/manifest-identity.js +17 -0
- package/shared/vendor/reploid/artifacts/participant-proofs.js +159 -0
- package/shared/vendor/reploid/artifacts/signatures.js +94 -0
- package/shared/vendor/reploid/config/defaults.json +110 -0
- package/shared/vendor/reploid/config/index.js +209 -0
- package/shared/vendor/reploid/config/request-overrides.json +9 -0
- package/shared/vendor/reploid/hashing.js +30 -0
- package/shared/vendor/reploid/mesh/generation-context-cache.js +97 -0
- package/shared/vendor/reploid/mesh/partitions/partition-attempt-evidence.js +282 -0
- package/shared/vendor/reploid/mesh/partitions/partition-contract.js +192 -0
- package/shared/vendor/reploid/mesh/partitions/partition-receiver-policy.json +7 -0
- package/shared/vendor/reploid/mesh/partitions/partition-route-ranking.js +268 -0
- package/shared/vendor/reploid/mesh/preparation-progress.js +46 -0
- package/shared/vendor/reploid/mesh/provider-hardware.js +11 -0
- package/shared/vendor/reploid/rules/routing.rules.json +24 -0
- package/shared/vendor/reploid/transport/partition-errors.json +16 -0
- package/README.md +0 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import policy from './gpu-signature.policy.json' with { type: 'json' };
|
|
2
|
+
import { gpuSignatureShader } from './gpu-signature-shader.js';
|
|
3
|
+
import { publicProviderHardware } from './provider-hardware.js';
|
|
4
|
+
|
|
5
|
+
const active = new WeakSet();
|
|
6
|
+
const permutation = row => Array.isArray(row) && row.length === policy.workgroups
|
|
7
|
+
&& row.every(value => Number.isInteger(value) && value >= 0 && value < policy.workgroups)
|
|
8
|
+
&& new Set(row).size === policy.workgroups;
|
|
9
|
+
|
|
10
|
+
function summarize(signature) {
|
|
11
|
+
if (!signature || signature.schema !== policy.schema || signature.profile !== policy.profile
|
|
12
|
+
|| signature.status !== 'measured' || signature.workgroups !== policy.workgroups
|
|
13
|
+
|| signature.trials !== policy.trials || !Array.isArray(signature.samples)
|
|
14
|
+
|| signature.samples.length !== policy.seeds.length) throw new TypeError('Invalid GPU signature');
|
|
15
|
+
const means = [], deviations = [];
|
|
16
|
+
for (const [index, sample] of signature.samples.entries()) {
|
|
17
|
+
if (sample.seed !== policy.seeds[index] || sample.workload !== index
|
|
18
|
+
|| !Array.isArray(sample.orders) || sample.orders.length !== policy.trials
|
|
19
|
+
|| !sample.orders.every(permutation)) throw new TypeError('Invalid GPU signature samples');
|
|
20
|
+
for (let group = 0; group < policy.workgroups; group++) {
|
|
21
|
+
const values = sample.orders.map(row => row[group] / (policy.workgroups - 1));
|
|
22
|
+
const mean = values.reduce((a, b) => a + b, 0) / values.length;
|
|
23
|
+
means.push(mean);
|
|
24
|
+
deviations.push(Math.sqrt(values.reduce((sum, value) => sum + (value - mean) ** 2, 0) / values.length));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return { means, deviations };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Measures the LOCAL GPU only. No identifier, storage write, or network upload.
|
|
31
|
+
* The caller must opt in. Cancellation stops new dispatches; submitted work is bounded,
|
|
32
|
+
* not forcibly preempted. A borrowed device is never destroyed.
|
|
33
|
+
*/
|
|
34
|
+
export async function captureGpuSignature(device = null, { consent = false, signal,
|
|
35
|
+
gpu = globalThis.navigator?.gpu } = {}) {
|
|
36
|
+
if (consent !== true) throw new Error('GPU signature collection requires explicit consent');
|
|
37
|
+
signal?.throwIfAborted();
|
|
38
|
+
if (!device && !gpu?.requestAdapter) return { status: 'unavailable', reason: 'webgpu-unavailable' };
|
|
39
|
+
if (device && active.has(device)) throw new Error('GPU signature measurement is already running on this device');
|
|
40
|
+
const started = performance.now(), buffers = [];
|
|
41
|
+
const owned = !device;
|
|
42
|
+
let timer, cancel, finished = false, hardware = null;
|
|
43
|
+
const interrupted = new Promise((_, reject) => {
|
|
44
|
+
timer = setTimeout(() => reject(new Error('GPU signature measurement timed out')), policy.timeoutMs);
|
|
45
|
+
cancel = () => reject(signal.reason || new Error('GPU signature measurement cancelled'));
|
|
46
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
47
|
+
});
|
|
48
|
+
// Attach a rejection handler even if setup fails before the first await.
|
|
49
|
+
interrupted.catch(() => {});
|
|
50
|
+
let lost;
|
|
51
|
+
const wait = promise => Promise.race([promise, interrupted, ...(lost ? [lost] : [])]);
|
|
52
|
+
try {
|
|
53
|
+
if (!device) {
|
|
54
|
+
const adapter = await wait(gpu.requestAdapter());
|
|
55
|
+
if (!adapter) return { status: 'unavailable', reason: 'adapter-unavailable' };
|
|
56
|
+
if (adapter.info?.isFallbackAdapter) return { status: 'unavailable', reason: 'software-adapter' };
|
|
57
|
+
hardware = publicProviderHardware(adapter.info);
|
|
58
|
+
device = await wait(adapter.requestDevice().then(created => {
|
|
59
|
+
if (finished) { created.destroy(); throw new Error('GPU signature acquisition expired'); }
|
|
60
|
+
return created;
|
|
61
|
+
}));
|
|
62
|
+
} else hardware = publicProviderHardware(device.adapterInfo);
|
|
63
|
+
active.add(device);
|
|
64
|
+
lost = device.lost.then(info => { throw new Error('GPU device lost: ' + info.reason); });
|
|
65
|
+
lost.catch(() => {});
|
|
66
|
+
const makeBuffer = (size, usage) => {
|
|
67
|
+
const buffer = device.createBuffer({ size, usage }); buffers.push(buffer); return buffer;
|
|
68
|
+
};
|
|
69
|
+
const outputBytes = (1 + 2 * policy.workgroups) * 4;
|
|
70
|
+
const params = makeBuffer(16, GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST);
|
|
71
|
+
const input = makeBuffer(policy.dataWords * 4, GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST);
|
|
72
|
+
const result = makeBuffer(outputBytes, GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC | GPUBufferUsage.COPY_DST);
|
|
73
|
+
const readback = makeBuffer(outputBytes, GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST);
|
|
74
|
+
const data = Uint32Array.from({ length: policy.dataWords }, (_, i) => Math.imul(i + 1, 2654435761) >>> 0);
|
|
75
|
+
device.queue.writeBuffer(input, 0, data);
|
|
76
|
+
const module = device.createShaderModule({ code: gpuSignatureShader });
|
|
77
|
+
const pipeline = await wait(device.createComputePipelineAsync({ layout: 'auto', compute: { module, entryPoint: 'main' } }));
|
|
78
|
+
const bindings = device.createBindGroup({ layout: pipeline.getBindGroupLayout(0),
|
|
79
|
+
entries: [params, input, result].map((buffer, binding) => ({ binding, resource: { buffer } })) });
|
|
80
|
+
const samples = [];
|
|
81
|
+
for (let workload = 0; workload < policy.seeds.length; workload++) {
|
|
82
|
+
const seed = policy.seeds[workload], orders = [], checksums = [];
|
|
83
|
+
// Discard one dispatch per workload for compilation/initial scheduling effects.
|
|
84
|
+
for (let trial = -1; trial < policy.trials; trial++) {
|
|
85
|
+
signal?.throwIfAborted();
|
|
86
|
+
device.queue.writeBuffer(params, 0, new Uint32Array([seed, workload, 0, 0]));
|
|
87
|
+
device.queue.writeBuffer(result, 0, new Uint32Array(outputBytes / 4));
|
|
88
|
+
const encoder = device.createCommandEncoder(), pass = encoder.beginComputePass();
|
|
89
|
+
pass.setPipeline(pipeline); pass.setBindGroup(0, bindings); pass.dispatchWorkgroups(policy.workgroups); pass.end();
|
|
90
|
+
encoder.copyBufferToBuffer(result, 0, readback, 0, outputBytes);
|
|
91
|
+
device.queue.submit([encoder.finish()]);
|
|
92
|
+
await wait(readback.mapAsync(GPUMapMode.READ));
|
|
93
|
+
const words = new Uint32Array(readback.getMappedRange()).slice();
|
|
94
|
+
readback.unmap();
|
|
95
|
+
const order = Array.from(words.slice(1, 1 + policy.workgroups));
|
|
96
|
+
if (words[0] !== policy.workgroups || !permutation(order)) throw new Error('GPU signature dispatch returned incomplete results');
|
|
97
|
+
if (trial >= 0) { orders.push(order); checksums.push(Array.from(words.slice(1 + policy.workgroups))); }
|
|
98
|
+
}
|
|
99
|
+
samples.push({ workload, seed, orders, checksums });
|
|
100
|
+
}
|
|
101
|
+
signal?.throwIfAborted();
|
|
102
|
+
const signature = { schema: policy.schema, profile: policy.profile, status: 'measured',
|
|
103
|
+
source: 'local-webgpu', hardware, workgroups: policy.workgroups, trials: policy.trials,
|
|
104
|
+
collectedAt: new Date().toISOString(), elapsedMs: performance.now() - started,
|
|
105
|
+
allocationBytes: buffers.reduce((sum, buffer) => sum + buffer.size, 0), samples };
|
|
106
|
+
return { ...signature, statistics: summarize(signature) };
|
|
107
|
+
} finally {
|
|
108
|
+
finished = true;
|
|
109
|
+
clearTimeout(timer); signal?.removeEventListener('abort', cancel);
|
|
110
|
+
for (const buffer of buffers) buffer.destroy();
|
|
111
|
+
if (device) { active.delete(device); if (owned) device.destroy(); }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Distance is descriptive. Thresholds must be supplied with a calibration reference;
|
|
116
|
+
* no default threshold claims that a signature identifies a physical GPU.
|
|
117
|
+
*/
|
|
118
|
+
export function compareGpuSignatures(baseline, candidate, thresholds = null) {
|
|
119
|
+
if (!baseline || !candidate || baseline.status !== 'measured' || candidate.status !== 'measured') {
|
|
120
|
+
return { status: 'unmeasured', distance: null, reason: 'missing-measurement' };
|
|
121
|
+
}
|
|
122
|
+
if (baseline.profile !== candidate.profile || baseline.schema !== candidate.schema) {
|
|
123
|
+
return { status: 'uncertain', distance: null, reason: 'incompatible-profiles' };
|
|
124
|
+
}
|
|
125
|
+
const a = summarize(baseline), b = summarize(candidate);
|
|
126
|
+
const distance = Math.sqrt(a.means.reduce((sum, mean, i) => sum + (mean - b.means[i]) ** 2, 0) / a.means.length);
|
|
127
|
+
const variability = Math.sqrt([...a.deviations, ...b.deviations].reduce((sum, value) => sum + value ** 2, 0) / (a.means.length * 2));
|
|
128
|
+
if (!thresholds) return { status: 'uncertain', distance, variability, reason: 'calibration-required' };
|
|
129
|
+
const { calibrationId, consistentMax, changedMin } = thresholds;
|
|
130
|
+
if (typeof calibrationId !== 'string' || !calibrationId.trim() || !Number.isFinite(consistentMax)
|
|
131
|
+
|| !Number.isFinite(changedMin) || consistentMax < 0 || changedMin <= consistentMax || changedMin > 1) {
|
|
132
|
+
throw new TypeError('GPU comparison needs calibrated distance thresholds and a calibrationId');
|
|
133
|
+
}
|
|
134
|
+
const status = distance <= consistentMax ? 'consistent' : distance >= changedMin ? 'changed' : 'uncertain';
|
|
135
|
+
return { status, distance, variability, calibrationId, consistentMax, changedMin, reason: 'signature-distance-only' };
|
|
136
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export { createPeerGenerationMesh } from './peer-generation.js';
|
|
2
|
+
export { identifyComputer, participantLabel } from './computer-identity.js';
|
|
3
|
+
export { captureGpuSignature, compareGpuSignatures } from './gpu-signature.js';
|
|
4
|
+
export { projectPlacementBeliefs, resolvePlacementBeliefPolicy } from './placement-beliefs.js';
|
|
5
|
+
export * from './swarm-coordination.js';
|
|
6
|
+
export * from './partitions/partition-runner.js';
|
|
7
|
+
export * from './partitions/partition-step-receiver.js';
|
|
8
|
+
export * from './contribution.js';
|
|
9
|
+
export { default as contributionPolicy } from './contribution.js';
|
|
10
|
+
export { default as swarmCoordination } from './swarm-coordination.js';
|
|
11
|
+
import routing from '../rules/routing.rules.json' with { type: 'json' };
|
|
12
|
+
import { requireResolvedConfig, snapshotJson } from '../config/index.js';
|
|
13
|
+
|
|
14
|
+
export function createIntelligenceMesh({ config, ports }) {
|
|
15
|
+
const policy = requireResolvedConfig(config);
|
|
16
|
+
if (typeof ports?.authorize !== 'function') throw new TypeError('Mesh host authorization is required');
|
|
17
|
+
const order = routing.rules.find(rule => rule.id === policy.mesh.routing).order;
|
|
18
|
+
let closed = false;
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
async connect() {
|
|
21
|
+
if (closed || !policy.mesh.enabled) throw new Error('Mesh connection is disabled');
|
|
22
|
+
if (await ports.authorize({ action: 'mesh.connect', roomId: policy.mesh.roomId }) !== true) throw new Error('Host denied mesh connection');
|
|
23
|
+
if (!ports.remote?.connect) throw new Error('A configured protocol adapter is required');
|
|
24
|
+
return ports.remote.connect();
|
|
25
|
+
},
|
|
26
|
+
async generate(messages, onUpdate, { signal } = {}) {
|
|
27
|
+
if (closed) throw new Error('Mesh is closed');
|
|
28
|
+
signal?.throwIfAborted();
|
|
29
|
+
for (const placement of order) {
|
|
30
|
+
const provider = ports[placement];
|
|
31
|
+
if (!provider) continue;
|
|
32
|
+
if (placement === 'remote' && (!policy.mesh.enabled || !provider.hasAvailableProvider?.())) continue;
|
|
33
|
+
if (await ports.authorize({ action: 'mesh.place', placement, contract: policy.models.contract }) !== true) continue;
|
|
34
|
+
// Placement is chosen before execution. Execution failure never silently
|
|
35
|
+
// retries private data on another provider.
|
|
36
|
+
return provider.generate(snapshotJson(messages), onUpdate, { signal });
|
|
37
|
+
}
|
|
38
|
+
throw new Error('No authorized compatible execution placement');
|
|
39
|
+
},
|
|
40
|
+
describe() {
|
|
41
|
+
return snapshotJson({ schema: 'reploid.mesh-state/v1', enabled: policy.mesh.enabled,
|
|
42
|
+
permissions: { executeJobs: policy.mesh.executeJobs, supplyArtifacts: policy.mesh.supplyArtifacts, shareCandidates: policy.mesh.shareCandidates },
|
|
43
|
+
local: !!ports.local, remote: ports.remote?.getSwarmSnapshot?.() || null, modelContract: policy.models.contract,
|
|
44
|
+
publicQualification: null });
|
|
45
|
+
},
|
|
46
|
+
async close() { closed = true; }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export * from './partitions/resident-partition.js';
|
|
51
|
+
export * from './partitions/partition-grants.js';
|
|
52
|
+
export * from './partitions/partition-stage-commit.js';
|
|
53
|
+
export * from './partitions/partition-peer.js';
|
|
54
|
+
export * from './partitions/partition-network.js';
|
|
55
|
+
export * from './partitions/partition-chat.js';
|
|
56
|
+
export { partitionFingerprint, PARTITION_ROUTE_SCHEMA, ROUTE_ATTEMPT_SCHEMA, validatePartitionRoute,
|
|
57
|
+
canonicalRouteAttemptBinding, sameRouteAttemptIdentity } from './partitions/partition-contract.js';
|
|
58
|
+
export { selectPartitionRoute, validateOrderedPartitionCapability } from './partitions/partition-placement.js';
|
|
59
|
+
|
|
60
|
+
export * from './partitions/partition-entry.js';
|
|
61
|
+
export * from './partitions/partition-attempt-evidence.js';
|
|
62
|
+
export * from './partitions/partition-link.js';
|
|
63
|
+
|
|
64
|
+
export * from './partitions/automatic-partitions.js';
|
|
65
|
+
export * from './partitions/signed-resident-factory.js';
|
|
66
|
+
export * from './partitions/partition-preparation-progress.js';
|