instar 1.3.2031 → 1.3.2033
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/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +2 -1
- package/dist/commands/server.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +5 -0
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +10 -3
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/data/standards-guard-index.json +1 -1
- package/dist/data/standards-guard-index.meta.json +2 -2
- package/dist/data/standards-registry.meta.json +1 -1
- package/dist/localVerify/LocalVerifyService.d.ts +21 -0
- package/dist/localVerify/LocalVerifyService.d.ts.map +1 -1
- package/dist/localVerify/LocalVerifyService.js +325 -16
- package/dist/localVerify/LocalVerifyService.js.map +1 -1
- package/dist/localVerify/launchdSpawn.d.ts +2 -0
- package/dist/localVerify/launchdSpawn.d.ts.map +1 -1
- package/dist/localVerify/launchdSpawn.js +5 -3
- package/dist/localVerify/launchdSpawn.js.map +1 -1
- package/dist/localVerify/localVerifyRoutes.d.ts.map +1 -1
- package/dist/localVerify/localVerifyRoutes.js +36 -0
- package/dist/localVerify/localVerifyRoutes.js.map +1 -1
- package/dist/localVerify/localVerifyWiring.d.ts +2 -0
- package/dist/localVerify/localVerifyWiring.d.ts.map +1 -1
- package/dist/localVerify/localVerifyWiring.js +19 -1
- package/dist/localVerify/localVerifyWiring.js.map +1 -1
- package/dist/localVerify/peer.d.ts +13 -0
- package/dist/localVerify/peer.d.ts.map +1 -1
- package/dist/localVerify/peer.js +4 -1
- package/dist/localVerify/peer.js.map +1 -1
- package/dist/localVerify/record.d.ts +1 -0
- package/dist/localVerify/record.d.ts.map +1 -1
- package/dist/localVerify/record.js.map +1 -1
- package/dist/localVerify/runSmallPeerWatchdog.d.ts +2 -0
- package/dist/localVerify/runSmallPeerWatchdog.d.ts.map +1 -0
- package/dist/localVerify/runSmallPeerWatchdog.js +3 -0
- package/dist/localVerify/runSmallPeerWatchdog.js.map +1 -0
- package/dist/localVerify/smallPeerMemory.d.ts +35 -0
- package/dist/localVerify/smallPeerMemory.d.ts.map +1 -0
- package/dist/localVerify/smallPeerMemory.js +83 -0
- package/dist/localVerify/smallPeerMemory.js.map +1 -0
- package/dist/localVerify/smallPeerReceipts.d.ts +40 -0
- package/dist/localVerify/smallPeerReceipts.d.ts.map +1 -0
- package/dist/localVerify/smallPeerReceipts.js +221 -0
- package/dist/localVerify/smallPeerReceipts.js.map +1 -0
- package/dist/localVerify/smallPeerSupervisor.d.ts +5 -0
- package/dist/localVerify/smallPeerSupervisor.d.ts.map +1 -0
- package/dist/localVerify/smallPeerSupervisor.js +124 -0
- package/dist/localVerify/smallPeerSupervisor.js.map +1 -0
- package/dist/localVerify/smallPeerWatchdog.d.ts +27 -0
- package/dist/localVerify/smallPeerWatchdog.d.ts.map +1 -0
- package/dist/localVerify/smallPeerWatchdog.js +191 -0
- package/dist/localVerify/smallPeerWatchdog.js.map +1 -0
- package/dist/localVerify/trialExecutionScope.d.ts +42 -0
- package/dist/localVerify/trialExecutionScope.d.ts.map +1 -0
- package/dist/localVerify/trialExecutionScope.js +197 -0
- package/dist/localVerify/trialExecutionScope.js.map +1 -0
- package/dist/native/InstarWedgeCanary.app/Contents/MacOS/InstarWedgeCanary +0 -0
- package/dist/native/instar-desktop-host +0 -0
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +1 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +18 -3
- package/dist/server/routes.js.map +1 -1
- package/dist/testing/selfActionRegistry.d.ts.map +1 -1
- package/dist/testing/selfActionRegistry.js +23 -0
- package/dist/testing/selfActionRegistry.js.map +1 -1
- package/package.json +1 -1
- package/scripts/local-verify/probe-trial-scope.mjs +112 -0
- package/scripts/local-verify/probe-trial-watchdog.mjs +71 -0
- package/scripts/local-verify/trial-coalition.py +105 -0
- package/src/data/awareness/local-verify-main-on-peers.md +2 -0
- package/src/data/builtin-manifest.json +65 -65
- package/src/data/standards-guard-index.json +1 -1
- package/src/data/standards-guard-index.meta.json +2 -2
- package/src/data/standards-registry.meta.json +1 -1
- package/src/scaffold/templates.ts +1 -0
- package/upgrades/1.3.2032.md +16 -0
- package/upgrades/1.3.2033.md +20 -0
- package/upgrades/side-effects/local-verify-small-peer-trial.md +62 -0
- package/upgrades/side-effects/notification-injection-refusal.md +49 -0
|
@@ -68,6 +68,11 @@ import { requestDigest, signPeerResult, verifyPeerResult } from './peerResultSig
|
|
|
68
68
|
import { holdingDecision, keptHolding, noteDuration, refreshAgeMs, noteLocallyVerified, olderClock, peerMainRoutingAllowed, peersGreenOn, readPeerTrust, rememberPeerGreen, resetHoldingState, writePeerTrust } from './peerTrust.js';
|
|
69
69
|
import { PEER_LIMITS, cleanMarkerExtras, importRefusal, judgePeerAttempt, laneOfKey, markerCurrent, markerEpochDecision, noteFailure, noteSuccess, parsePeerMainRun, parsePeers, peerHealthy, } from './peer.js';
|
|
70
70
|
import { localVerifyRunPrefixes } from './leftoverReaper.js';
|
|
71
|
+
import { spawnSmallPeerSupervisor } from './smallPeerSupervisor.js';
|
|
72
|
+
import { acknowledgeTrial, bindTrial, finalizeInterruptedTrials, finishDelivery, importTrialPacket, localTrialReceipt, pendingTrialBindings, pendingTrialPackets, receivedTrial, validTrialReceipt } from './smallPeerReceipts.js';
|
|
73
|
+
import { trialDirectory } from './smallPeerWatchdog.js';
|
|
74
|
+
import { reconcileTrialScopes } from './trialExecutionScope.js';
|
|
75
|
+
import { SAMPLE_DEADLINE_MS, readSmallPeerMemory, smallPeerMemoryAllows, parseSmallPeerTrialPolicy } from './smallPeerMemory.js';
|
|
71
76
|
import { FIRST_PART_LIMITS, boundLikelyFailingWire, parseFirstPartSetting } from './firstPart.js';
|
|
72
77
|
import { LikelyFailingStore } from './likelyFailingList.js';
|
|
73
78
|
import { FirstPartGroups } from './firstPartTrial.js';
|
|
@@ -487,6 +492,10 @@ export class LocalVerifyService {
|
|
|
487
492
|
/** Coordinator: the configured peers (`monitoring.localVerify.peers`; absent ⇒ none). */
|
|
488
493
|
peersSetting = null;
|
|
489
494
|
peerClient = null;
|
|
495
|
+
trialHealthySince = null;
|
|
496
|
+
trialRecoveryPending = false;
|
|
497
|
+
trialAdmissionPending = false;
|
|
498
|
+
smallPeerTrialSetting = null;
|
|
490
499
|
/** Borrowed-machine shadow observer (never awaited; type-only dependency). */
|
|
491
500
|
mainRunObserver = null;
|
|
492
501
|
/** The run machine's borrowed-helper side (practice record, loopback proxy, baseline results); type-only dependency. */
|
|
@@ -918,7 +927,10 @@ export class LocalVerifyService {
|
|
|
918
927
|
this.mainObs.immediate = true; // the boot-time `main` verify skips the debounce
|
|
919
928
|
// Order matters: the orphan reap runs first, and a still-blocked reap keeps every
|
|
920
929
|
// restored entry waiting (pump refuses while blockedBy is set).
|
|
921
|
-
await this.reapOrphan()
|
|
930
|
+
if (await this.reapOrphan() !== 'incomplete') {
|
|
931
|
+
await reconcileTrialScopes(this.cfg.stateDir);
|
|
932
|
+
finalizeInterruptedTrials(this.cfg.stateDir, this.cfg.machineId);
|
|
933
|
+
}
|
|
922
934
|
this.loadPeerState(); // after the reap: an interrupted peer attempt is tombstoned, never resumed
|
|
923
935
|
await this.sweepLeftovers('boot');
|
|
924
936
|
await this.rebuildIndex();
|
|
@@ -1703,6 +1715,8 @@ export class LocalVerifyService {
|
|
|
1703
1715
|
// ---- peer verifiers (spec local-verify-capacity.md Part D) ----
|
|
1704
1716
|
/** Wire the peer settings (read at each use) and the coordinator's client and lease view. */
|
|
1705
1717
|
setPeerWiring(o) {
|
|
1718
|
+
if (o.smallPeerTrial !== undefined)
|
|
1719
|
+
this.smallPeerTrialSetting = o.smallPeerTrial;
|
|
1706
1720
|
if (o.signer !== undefined)
|
|
1707
1721
|
this.peerSigner = o.signer;
|
|
1708
1722
|
if (o.keyLookupFactory !== undefined)
|
|
@@ -1827,7 +1841,7 @@ export class LocalVerifyService {
|
|
|
1827
1841
|
fit = { eligible: true, reason: 'fit-unreadable', score: null };
|
|
1828
1842
|
} // @silent-fallback-ok: an unreadable fit keeps today's behaviour for that peer (no filter), never a silent drop
|
|
1829
1843
|
this.noteMemory(peer.machineId, fit.eligible ? null : (fit.memoryReason ?? null), 'peer');
|
|
1830
|
-
if (fit.eligible) {
|
|
1844
|
+
if (fit.eligible || (fit.smallPeerHeadroom && this.smallPeerPolicy(peer.machineId))) {
|
|
1831
1845
|
kept.push({ peer, score: typeof fit.score === 'number' && Number.isFinite(fit.score) ? fit.score : Number.POSITIVE_INFINITY, i });
|
|
1832
1846
|
return;
|
|
1833
1847
|
}
|
|
@@ -1841,6 +1855,63 @@ export class LocalVerifyService {
|
|
|
1841
1855
|
kept.sort((a, b) => (a.score - b.score) || (a.i - b.i));
|
|
1842
1856
|
return kept.map((k) => k.peer);
|
|
1843
1857
|
}
|
|
1858
|
+
smallPeerPolicy(machineId) {
|
|
1859
|
+
let p;
|
|
1860
|
+
try {
|
|
1861
|
+
p = parseSmallPeerTrialPolicy(this.smallPeerTrialSetting?.());
|
|
1862
|
+
}
|
|
1863
|
+
catch {
|
|
1864
|
+
return null;
|
|
1865
|
+
} // @silent-fallback-ok — unreadable settings never authorize a trial
|
|
1866
|
+
return p?.machineId === machineId ? p : null;
|
|
1867
|
+
}
|
|
1868
|
+
managesSmallPeer(policy) {
|
|
1869
|
+
const marker = path.join(this.lvStateDir, 'small-peer-managed');
|
|
1870
|
+
if (!policy)
|
|
1871
|
+
return fs.existsSync(marker);
|
|
1872
|
+
if (!fs.existsSync(marker)) {
|
|
1873
|
+
fs.mkdirSync(this.lvStateDir, { recursive: true, mode: 0o700 });
|
|
1874
|
+
fs.writeFileSync(marker, this.cfg.machineId, { mode: 0o600 });
|
|
1875
|
+
}
|
|
1876
|
+
return true;
|
|
1877
|
+
}
|
|
1878
|
+
trialPolicyCurrent(policy) {
|
|
1879
|
+
const shards = this.laneShards();
|
|
1880
|
+
return process.platform === 'darwin' && shards?.unitWorkers === 2 && shards.integration === 1 && shards.e2e === 1
|
|
1881
|
+
&& JSON.stringify(this.smallPeerPolicy(this.cfg.machineId)) === JSON.stringify(policy)
|
|
1882
|
+
&& !fs.existsSync(path.join(this.lvStateDir, 'small-peer-quarantined'));
|
|
1883
|
+
}
|
|
1884
|
+
beginTrialRecovery(policy, quarantine) {
|
|
1885
|
+
if (quarantine)
|
|
1886
|
+
fs.writeFileSync(path.join(this.lvStateDir, 'small-peer-quarantined'), 'recalibration required', { mode: 0o600 });
|
|
1887
|
+
const marker = path.join(this.lvStateDir, 'small-peer-recovering');
|
|
1888
|
+
fs.writeFileSync(marker, 'waiting for sustained healthy samples', { mode: 0o600 });
|
|
1889
|
+
if (this.trialRecoveryPending)
|
|
1890
|
+
return;
|
|
1891
|
+
this.trialRecoveryPending = true;
|
|
1892
|
+
this.trialHealthySince = null;
|
|
1893
|
+
let previousSample = -Infinity;
|
|
1894
|
+
const sample = async () => {
|
|
1895
|
+
if (this.stopped)
|
|
1896
|
+
return;
|
|
1897
|
+
const value = await readSmallPeerMemory();
|
|
1898
|
+
const now = performance.now();
|
|
1899
|
+
if (now - previousSample >= SAMPLE_DEADLINE_MS)
|
|
1900
|
+
this.trialHealthySince = null;
|
|
1901
|
+
previousSample = now;
|
|
1902
|
+
if (smallPeerMemoryAllows(value, policy.floorBytes, now))
|
|
1903
|
+
this.trialHealthySince ??= now;
|
|
1904
|
+
else
|
|
1905
|
+
this.trialHealthySince = null;
|
|
1906
|
+
if (this.trialHealthySince !== null && now - this.trialHealthySince >= policy.recoveryMs) {
|
|
1907
|
+
SafeFsExecutor.safeRmSync(marker, { force: true, operation: 'local-verify:small-peer-recovered' });
|
|
1908
|
+
this.trialRecoveryPending = false;
|
|
1909
|
+
}
|
|
1910
|
+
else
|
|
1911
|
+
setTimeout(() => void sample(), 1000).unref();
|
|
1912
|
+
};
|
|
1913
|
+
void sample();
|
|
1914
|
+
}
|
|
1844
1915
|
configuredPeers() {
|
|
1845
1916
|
if (this.cfg.peerOnly)
|
|
1846
1917
|
return [];
|
|
@@ -1983,7 +2054,7 @@ export class LocalVerifyService {
|
|
|
1983
2054
|
this.saveTrust();
|
|
1984
2055
|
const client = this.peerClient;
|
|
1985
2056
|
const lease = this.leaseState();
|
|
1986
|
-
const candidates = this.configuredPeers().filter((p) => p.machineId !== forPeer && !t.quarantine[p.machineId]);
|
|
2057
|
+
const candidates = this.configuredPeers().filter((p) => p.machineId !== forPeer && !this.smallPeerPolicy(p.machineId) && !t.quarantine[p.machineId]);
|
|
1987
2058
|
for (const peer of client && lease.holds ? candidates : []) {
|
|
1988
2059
|
const st = await client.status(peer).catch(() => null);
|
|
1989
2060
|
if (!st || st.inFlight || st.slotBusy || st.verifierVersion !== this.cfg.verifierVersion || st.policyHash !== this.policyHash)
|
|
@@ -2135,6 +2206,13 @@ export class LocalVerifyService {
|
|
|
2135
2206
|
this.audit({ event: 'peer-run-refused', attemptId: req.attemptId, pr: req.pr, reason });
|
|
2136
2207
|
return { ok: false, reason };
|
|
2137
2208
|
};
|
|
2209
|
+
const trial = this.smallPeerPolicy(this.cfg.machineId);
|
|
2210
|
+
const managedSmallPeer = this.managesSmallPeer(trial);
|
|
2211
|
+
if (managedSmallPeer || req.smallPeerTrial) {
|
|
2212
|
+
if (!trial || !req.smallPeerTrial || req.kind || !this.trialPolicyCurrent(trial)
|
|
2213
|
+
|| JSON.stringify(parseSmallPeerTrialPolicy(req.smallPeerTrial)) !== JSON.stringify(trial))
|
|
2214
|
+
return refuse('peer-disabled');
|
|
2215
|
+
}
|
|
2138
2216
|
if (!this.peerRoleOn() || this.stopped)
|
|
2139
2217
|
return refuse('peer-disabled');
|
|
2140
2218
|
if (ctx.holdsLease)
|
|
@@ -2216,17 +2294,52 @@ export class LocalVerifyService {
|
|
|
2216
2294
|
return refuse('peer-busy');
|
|
2217
2295
|
if (this.verifierChangedOnDisk())
|
|
2218
2296
|
return refuse('verifier-mismatch');
|
|
2297
|
+
if (trial) {
|
|
2298
|
+
if (!this.trialRecoveryPending && fs.existsSync(path.join(this.lvStateDir, 'small-peer-recovering')))
|
|
2299
|
+
this.beginTrialRecovery(trial, false);
|
|
2300
|
+
if (this.trialAdmissionPending || this.trialRecoveryPending)
|
|
2301
|
+
return refuse('peer-busy');
|
|
2302
|
+
this.trialAdmissionPending = true;
|
|
2303
|
+
try {
|
|
2304
|
+
const sample = await readSmallPeerMemory();
|
|
2305
|
+
const now = performance.now();
|
|
2306
|
+
if (!smallPeerMemoryAllows(sample, trial.floorBytes, now)) {
|
|
2307
|
+
this.trialHealthySince = null;
|
|
2308
|
+
return refuse('peer-busy');
|
|
2309
|
+
}
|
|
2310
|
+
const lease = this.leaseState();
|
|
2311
|
+
if (busy() || this.notePause() || this.stopped || !this.peerRoleOn() || !this.trialPolicyCurrent(trial)
|
|
2312
|
+
|| lease.holds || lease.holder !== req.coordinatorMachineId || lease.epoch !== req.leaseEpoch
|
|
2313
|
+
|| this.peerState.tombstones[req.attemptId] !== undefined || this.verifierChangedOnDisk())
|
|
2314
|
+
return refuse('peer-busy');
|
|
2315
|
+
if (this.trialRecoveryPending)
|
|
2316
|
+
return refuse('peer-busy');
|
|
2317
|
+
}
|
|
2318
|
+
finally {
|
|
2319
|
+
this.trialAdmissionPending = false;
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2219
2322
|
const entry = {
|
|
2220
2323
|
id: crypto.randomBytes(6).toString('hex'), pr: req.pr, headSha: req.headSha, baseSha: req.baseSha, baseRefName: req.baseRefName,
|
|
2221
2324
|
firstQueuedAt: this.now(), attempts: 0, errorRetries: 0, starvedRaised: false, priority: QUEUE_PRIORITY.ordinary,
|
|
2222
2325
|
...((req.kind === 'main' || req.kind === 'main-arbitration') ? { kind: 'main' } : {}),
|
|
2223
2326
|
peerAttempt: { id: req.attemptId, coordinatorMachineId: req.coordinatorMachineId, leaseEpoch: req.leaseEpoch },
|
|
2224
2327
|
...(req.preflightRediscoverable === true ? { preflightRediscoverable: true } : {}),
|
|
2328
|
+
...(trial ? { smallPeerTrial: trial } : {}),
|
|
2225
2329
|
...(req.isolation ? { peerIsolation: req.isolation } : {}),
|
|
2226
2330
|
...(req.kind === 'main' && req.fileCounts === true ? { peerFileCounts: true } : {}),
|
|
2227
2331
|
...(req.likelyFailing ? { peerLikelyFailing: req.likelyFailing } : {}),
|
|
2228
2332
|
...(req.firstPartGroup ? { peerFirstPartGroup: req.firstPartGroup } : {}),
|
|
2229
2333
|
};
|
|
2334
|
+
if (trial) {
|
|
2335
|
+
try {
|
|
2336
|
+
bindTrial(this.cfg.stateDir, req, this.cfg.machineId);
|
|
2337
|
+
}
|
|
2338
|
+
catch (err) {
|
|
2339
|
+
this.audit({ event: 'small-peer-binding-failed', detail: String(err) });
|
|
2340
|
+
return refuse('state-unwritable');
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2230
2343
|
this.peerState.current = { attemptId: req.attemptId, pr: req.pr, headSha: req.headSha, state: 'running', acceptedAt: this.now(), requestDigest: requestDigest(req) };
|
|
2231
2344
|
if (!this.persistPeerState()) {
|
|
2232
2345
|
// Without the durable record a restart could not tombstone this attempt: never start it.
|
|
@@ -2285,7 +2398,9 @@ export class LocalVerifyService {
|
|
|
2285
2398
|
/** Peer side: `GET /local-verify/peer-status`. */
|
|
2286
2399
|
peerStatus() {
|
|
2287
2400
|
const cur = this.peerState.current;
|
|
2401
|
+
const trial = this.smallPeerPolicy(this.cfg.machineId);
|
|
2288
2402
|
return {
|
|
2403
|
+
...(this.managesSmallPeer(trial) && trial && this.trialPolicyCurrent(trial) ? { smallPeerTrial: trial } : {}),
|
|
2289
2404
|
enabled: this.peerRoleOn(),
|
|
2290
2405
|
inFlight: cur && cur.state === 'running' ? { attemptId: cur.attemptId, pr: cur.pr } : null,
|
|
2291
2406
|
verifierVersion: this.cfg.verifierVersion,
|
|
@@ -2296,6 +2411,54 @@ export class LocalVerifyService {
|
|
|
2296
2411
|
...this.borrowedCall('peer-status', (s) => s.peerStatusExtras(), {}),
|
|
2297
2412
|
};
|
|
2298
2413
|
}
|
|
2414
|
+
trialLease(attemptId, coordinator, epoch, nonce) {
|
|
2415
|
+
const f = this.inFlight;
|
|
2416
|
+
const policy = f?.entry.smallPeerTrial;
|
|
2417
|
+
const lease = this.leaseState();
|
|
2418
|
+
const now = performance.now();
|
|
2419
|
+
if (!f?.trialHandle || !policy || f.entry.peerAttempt?.id !== attemptId || f.cancelled || this.stopped
|
|
2420
|
+
|| lease.holds || lease.epoch !== epoch || lease.holder !== coordinator || !this.trialPolicyCurrent(policy)
|
|
2421
|
+
|| now >= (f.trialExpiresAt ?? 0))
|
|
2422
|
+
return null;
|
|
2423
|
+
if (nonce !== undefined) {
|
|
2424
|
+
const challenge = f.trialLease;
|
|
2425
|
+
if (!challenge || challenge.nonce !== nonce || now >= challenge.issuedAt + 10_000)
|
|
2426
|
+
return null;
|
|
2427
|
+
delete f.trialLease;
|
|
2428
|
+
f.trialExpiresAt = challenge.issuedAt + 10_000;
|
|
2429
|
+
// Host-monotonic uptime remains comparable across the local IPC boundary, even when delivery is delayed.
|
|
2430
|
+
f.trialHandle.renewTrial?.(Number(process.hrtime.bigint() / 1000000n) + f.trialExpiresAt - now);
|
|
2431
|
+
return nonce;
|
|
2432
|
+
}
|
|
2433
|
+
f.trialLease = { nonce: crypto.randomBytes(16).toString('hex'), issuedAt: now };
|
|
2434
|
+
return f.trialLease.nonce;
|
|
2435
|
+
}
|
|
2436
|
+
startTrialRenewal(peer, entry, m, trial, epoch) {
|
|
2437
|
+
const client = this.peerClient;
|
|
2438
|
+
if (!client?.trialLease || epoch === null)
|
|
2439
|
+
return;
|
|
2440
|
+
const valid = () => {
|
|
2441
|
+
const l = this.leaseState();
|
|
2442
|
+
return !this.stopped && this.queue.includes(entry) && entry.remote === m && l.holds && l.epoch === epoch
|
|
2443
|
+
&& JSON.stringify(this.smallPeerPolicy(peer.machineId)) === JSON.stringify(trial);
|
|
2444
|
+
};
|
|
2445
|
+
const tick = async () => {
|
|
2446
|
+
if (!valid())
|
|
2447
|
+
return;
|
|
2448
|
+
const req = { attemptId: m.attemptId, coordinatorMachineId: this.cfg.machineId, leaseEpoch: epoch };
|
|
2449
|
+
try {
|
|
2450
|
+
const nonce = await client.trialLease(peer, req);
|
|
2451
|
+
if (nonce && valid())
|
|
2452
|
+
await client.trialLease(peer, { ...req, nonce });
|
|
2453
|
+
}
|
|
2454
|
+
catch (e) {
|
|
2455
|
+
this.audit({ event: 'small-peer-renewal-unavailable', pr: entry.pr, detail: String(e) });
|
|
2456
|
+
}
|
|
2457
|
+
if (valid())
|
|
2458
|
+
setTimeout(() => void tick(), 3000).unref();
|
|
2459
|
+
};
|
|
2460
|
+
void tick();
|
|
2461
|
+
}
|
|
2299
2462
|
peerSignerKeyHash() {
|
|
2300
2463
|
try {
|
|
2301
2464
|
return this.peerSigner ? this.peerSigner.signerKeyHash() : null;
|
|
@@ -2304,6 +2467,54 @@ export class LocalVerifyService {
|
|
|
2304
2467
|
return null;
|
|
2305
2468
|
} // @silent-fallback-ok — the hint is optional; a missing one only skips the coordinator's pre-check
|
|
2306
2469
|
}
|
|
2470
|
+
trialReceiptsFor(coordinator, attemptIds) {
|
|
2471
|
+
return this.peerSigner ? pendingTrialPackets(this.cfg.stateDir, coordinator, this.peerSigner, attemptIds) : [];
|
|
2472
|
+
}
|
|
2473
|
+
acknowledgeTrialReceipt(ack) {
|
|
2474
|
+
return !!this.peerKeyLookupFactory && acknowledgeTrial(this.cfg.stateDir, ack, this.now(), this.peerKeyLookupFactory());
|
|
2475
|
+
}
|
|
2476
|
+
trialReceiptPollAt = 0;
|
|
2477
|
+
async recoverTrialReceipts() {
|
|
2478
|
+
const client = this.peerClient;
|
|
2479
|
+
if (!client?.trialReceipts || !client.acknowledgeTrial || !this.peerSigner || !this.peerKeyLookupFactory || !this.leaseState().holds)
|
|
2480
|
+
return;
|
|
2481
|
+
if (this.now() - this.trialReceiptPollAt < PEER_LIMITS.pollMs)
|
|
2482
|
+
return;
|
|
2483
|
+
this.trialReceiptPollAt = this.now();
|
|
2484
|
+
const pending = pendingTrialBindings(this.cfg.stateDir);
|
|
2485
|
+
if (pending.length === 0)
|
|
2486
|
+
return;
|
|
2487
|
+
for (const peer of this.configuredPeers()) {
|
|
2488
|
+
const outstanding = pending.filter(b => b.peer === peer.machineId && b.coordinator === this.cfg.machineId);
|
|
2489
|
+
if (outstanding.length === 0)
|
|
2490
|
+
continue;
|
|
2491
|
+
// Retry a committed receipt's acknowledgement even if the previous POST reached
|
|
2492
|
+
// the peer and its response was lost. Its outbox may already be clear.
|
|
2493
|
+
const saved = outstanding.flatMap(b => receivedTrial(this.cfg.stateDir, b.attemptId) ?? []);
|
|
2494
|
+
const packets = [];
|
|
2495
|
+
const outstandingIds = outstanding.map(b => b.attemptId);
|
|
2496
|
+
for (let i = 0; i < outstandingIds.length; i += 8) {
|
|
2497
|
+
if (!this.leaseState().holds)
|
|
2498
|
+
return;
|
|
2499
|
+
packets.push(...await client.trialReceipts(peer, this.cfg.machineId, outstandingIds.slice(i, i + 8)));
|
|
2500
|
+
}
|
|
2501
|
+
const byAttempt = new Map([...saved, ...packets].map(p => [p?.binding?.attemptId, p]));
|
|
2502
|
+
for (const packet of byAttempt.values()) {
|
|
2503
|
+
if (!this.leaseState().holds)
|
|
2504
|
+
return;
|
|
2505
|
+
try {
|
|
2506
|
+
const { ack, fresh } = importTrialPacket(this.cfg.stateDir, packet, peer.machineId, this.now(), this.peerKeyLookupFactory(), this.peerSigner);
|
|
2507
|
+
if (fresh)
|
|
2508
|
+
this.audit({ event: 'small-peer-receipt-imported', ...packet.binding, receipt: packet.receipt });
|
|
2509
|
+
if (await client.acknowledgeTrial(peer, ack))
|
|
2510
|
+
finishDelivery(this.cfg.stateDir, ack.attemptId);
|
|
2511
|
+
}
|
|
2512
|
+
catch (err) {
|
|
2513
|
+
this.audit({ event: 'small-peer-receipt-refused', peer: peer.machineId, detail: String(err) });
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2307
2518
|
/** Peer side: `GET /local-verify/peer-result`. */
|
|
2308
2519
|
peerResult(attemptId) {
|
|
2309
2520
|
const cur = this.peerState.current;
|
|
@@ -2487,6 +2698,16 @@ export class LocalVerifyService {
|
|
|
2487
2698
|
if (record.kind !== 'main' && f.runInput?.firstPartEvidence)
|
|
2488
2699
|
record.firstPart = f.runInput.firstPartEvidence;
|
|
2489
2700
|
}
|
|
2701
|
+
if (f.entry.smallPeerTrial) {
|
|
2702
|
+
try {
|
|
2703
|
+
const receipt = localTrialReceipt(this.cfg.stateDir, id);
|
|
2704
|
+
if (receipt)
|
|
2705
|
+
record.smallPeerReceipt = receipt;
|
|
2706
|
+
}
|
|
2707
|
+
catch (err) {
|
|
2708
|
+
this.audit({ event: 'small-peer-receipt-refused', attemptId: id, detail: String(err) });
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2490
2711
|
this.noteFirstPart(f, { ...(r ?? {}), kind: 'record', record });
|
|
2491
2712
|
// A red `main` run also hands over which files failed: the record itself may not carry them.
|
|
2492
2713
|
// A green one the coordinator asked per-file counts of hands those over (and nothing else).
|
|
@@ -2608,6 +2829,9 @@ export class LocalVerifyService {
|
|
|
2608
2829
|
this.borrowedCall('peer-status-read', (b) => b.onPeerStatus(peer, { ...(st.helperEvents ? { helperEvents: st.helperEvents } : {}), ...(st.wantsBaseline ? { wantsBaseline: true } : {}), ...(st.helpers ? { helpers: st.helpers } : {}) }), undefined);
|
|
2609
2830
|
}
|
|
2610
2831
|
const st = h.status;
|
|
2832
|
+
const trial = this.smallPeerPolicy(peer.machineId);
|
|
2833
|
+
if (trial && JSON.stringify(parseSmallPeerTrialPolicy(st?.smallPeerTrial)) !== JSON.stringify(trial))
|
|
2834
|
+
continue;
|
|
2611
2835
|
this.notePeerSkew(peer.machineId, h);
|
|
2612
2836
|
if (!st || st.inFlight || st.slotBusy || st.verifierVersion !== this.cfg.verifierVersion || st.policyHash !== this.policyHash)
|
|
2613
2837
|
continue;
|
|
@@ -2624,7 +2848,7 @@ export class LocalVerifyService {
|
|
|
2624
2848
|
const hold = this.holdDecision();
|
|
2625
2849
|
const held = new Set(hold.active ? hold.heldPrs.map((x) => x.pr) : []);
|
|
2626
2850
|
const sorted = this.orderQueue([...this.queue], this.now());
|
|
2627
|
-
let chosen = sorted.find((e) => (!restartPause || e.kind !== 'main') && this.dispatchable(e, held));
|
|
2851
|
+
let chosen = sorted.find((e) => (!(restartPause || trial) || e.kind !== 'main') && this.dispatchable(e, held));
|
|
2628
2852
|
if (!chosen)
|
|
2629
2853
|
return null;
|
|
2630
2854
|
if (chosen.kind === 'main') {
|
|
@@ -2706,12 +2930,16 @@ export class LocalVerifyService {
|
|
|
2706
2930
|
pi--;
|
|
2707
2931
|
continue;
|
|
2708
2932
|
}
|
|
2933
|
+
if (trial && (JSON.stringify(this.smallPeerPolicy(peer.machineId)) !== JSON.stringify(trial)
|
|
2934
|
+
|| !this.peerFitFn?.(peer.machineId).smallPeerHeadroom || entry.kind === 'main'))
|
|
2935
|
+
continue;
|
|
2709
2936
|
// The head is fixed here, before the snapshot: a reserved entry is never retargeted.
|
|
2710
2937
|
if (entry.kind === 'main')
|
|
2711
2938
|
this.retargetStaleMain(entry);
|
|
2712
2939
|
// Computed ONCE, before the marker exists: the list that is sent is the list the marker remembers.
|
|
2713
2940
|
const iso = entry.kind === 'main' ? null : this.isolationInput();
|
|
2714
2941
|
const marker = {
|
|
2942
|
+
...(trial ? { trialReceiptExpected: true } : {}),
|
|
2715
2943
|
machineId: peer.machineId, attemptId: crypto.randomBytes(16).toString('hex'), leaseEpoch: lease.epoch,
|
|
2716
2944
|
sentAt: this.now(), state: 'sending',
|
|
2717
2945
|
dispatched: { pr: entry.pr, headSha: entry.headSha, baseSha: entry.baseSha, baseRefName: entry.baseRefName, verifierVersion: this.cfg.verifierVersion, policyHash: this.policyHash,
|
|
@@ -2728,6 +2956,7 @@ export class LocalVerifyService {
|
|
|
2728
2956
|
}
|
|
2729
2957
|
const isMain = entry.kind === 'main';
|
|
2730
2958
|
const req = {
|
|
2959
|
+
...(trial ? { smallPeerTrial: trial } : {}),
|
|
2731
2960
|
attemptId: marker.attemptId, ...marker.dispatched, coordinatorMachineId: this.cfg.machineId, leaseEpoch: marker.leaseEpoch,
|
|
2732
2961
|
...(iso ? { isolation: { allowed: iso.allowed, notCleanOnGreenMain: [...iso.notCleanOnGreenMain], importRelatedRerun: iso.importRelatedRerun, flakyOnMain: iso.flakyOnMain } } : {}),
|
|
2733
2962
|
...(entry.preflightRediscoverable === true ? { preflightRediscoverable: true } : {}),
|
|
@@ -2737,6 +2966,15 @@ export class LocalVerifyService {
|
|
|
2737
2966
|
};
|
|
2738
2967
|
// SEC-113 D1: the digest of exactly what is sent; the peer signs it back with its answer.
|
|
2739
2968
|
marker.requestDigest = requestDigest(req);
|
|
2969
|
+
if (trial) {
|
|
2970
|
+
try {
|
|
2971
|
+
bindTrial(this.cfg.stateDir, req, peer.machineId, true);
|
|
2972
|
+
}
|
|
2973
|
+
catch (err) {
|
|
2974
|
+
this.audit({ event: 'small-peer-binding-failed', detail: String(err) });
|
|
2975
|
+
continue;
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2740
2978
|
entry.remote = marker;
|
|
2741
2979
|
entry.remoteAttempts = (entry.remoteAttempts ?? 0) + 1;
|
|
2742
2980
|
if (!this.persistQueue()) { // durable intent BEFORE the send, or no send at all
|
|
@@ -2758,6 +2996,8 @@ export class LocalVerifyService {
|
|
|
2758
2996
|
this.mainRunOnCurrentHead = curHead !== null && (entry.headSha === curHead || this.releaseAlias.get(curHead) === entry.headSha) ? entry.headSha : null;
|
|
2759
2997
|
}
|
|
2760
2998
|
const ans = await client.run(peer, req).catch(() => null);
|
|
2999
|
+
if (trial && ans && !ans.ok)
|
|
3000
|
+
finishDelivery(this.cfg.stateDir, marker.attemptId);
|
|
2761
3001
|
if (entry.remote !== marker)
|
|
2762
3002
|
continue; // abandoned meanwhile
|
|
2763
3003
|
if (ans === null) {
|
|
@@ -2765,6 +3005,8 @@ export class LocalVerifyService {
|
|
|
2765
3005
|
}
|
|
2766
3006
|
else if (ans.ok) {
|
|
2767
3007
|
marker.state = 'accepted';
|
|
3008
|
+
if (trial)
|
|
3009
|
+
this.startTrialRenewal(peer, entry, marker, trial, req.leaseEpoch);
|
|
2768
3010
|
this.remoteLastOkAt.set(marker.attemptId, this.now()); // the accept was a successful round trip
|
|
2769
3011
|
this.audit({ event: 'peer-dispatch-accepted', pr: entry.pr, peer: peer.machineId, attemptId: marker.attemptId });
|
|
2770
3012
|
if (isMain) {
|
|
@@ -2944,11 +3186,20 @@ export class LocalVerifyService {
|
|
|
2944
3186
|
if (this.pollRunning || this.cfg.peerOnly)
|
|
2945
3187
|
return;
|
|
2946
3188
|
const reserved = this.queue.filter((e) => e.remote);
|
|
2947
|
-
if (reserved.length === 0)
|
|
2948
|
-
return;
|
|
2949
3189
|
this.pollRunning = true;
|
|
2950
3190
|
try {
|
|
2951
|
-
|
|
3191
|
+
// Ordinary attempts can start polling immediately. Trial attempts must
|
|
3192
|
+
// look for a recovered receipt before judging a terminal peer response.
|
|
3193
|
+
const ordered = [
|
|
3194
|
+
...reserved.filter(entry => !entry.remote?.trialReceiptExpected),
|
|
3195
|
+
...reserved.filter(entry => entry.remote?.trialReceiptExpected),
|
|
3196
|
+
];
|
|
3197
|
+
let receiptsChecked = false;
|
|
3198
|
+
for (const entry of ordered) {
|
|
3199
|
+
if (entry.remote?.trialReceiptExpected && !receiptsChecked) {
|
|
3200
|
+
await this.recoverTrialReceipts();
|
|
3201
|
+
receiptsChecked = true;
|
|
3202
|
+
}
|
|
2952
3203
|
const m = entry.remote;
|
|
2953
3204
|
if (!m)
|
|
2954
3205
|
continue;
|
|
@@ -2969,6 +3220,11 @@ export class LocalVerifyService {
|
|
|
2969
3220
|
this.persistQueue(); // before the next await
|
|
2970
3221
|
this.audit({ event: 'peer-attempt-adopted', pr: entry.pr, attemptId: m.attemptId, fromEpoch: decision.fromEpoch, toEpoch: decision.toEpoch });
|
|
2971
3222
|
}
|
|
3223
|
+
const trialReceipt = m.trialReceiptExpected ? receivedTrial(this.cfg.stateDir, m.attemptId) : null;
|
|
3224
|
+
if (decision.action !== 'wait' && trialReceipt?.receipt.outcome === 'capacity') {
|
|
3225
|
+
this.abandonRemote(entry, 'small-peer-capacity', { failure: false, cancel: false });
|
|
3226
|
+
continue;
|
|
3227
|
+
}
|
|
2972
3228
|
const waiting = decision.action === 'wait';
|
|
2973
3229
|
if (decision.action === 'wait') {
|
|
2974
3230
|
const key = `${m.attemptId}:${lease.epoch}`;
|
|
@@ -3083,6 +3339,18 @@ export class LocalVerifyService {
|
|
|
3083
3339
|
this.notePeerResultTampered(peer, h, unverified);
|
|
3084
3340
|
continue;
|
|
3085
3341
|
}
|
|
3342
|
+
if (m.trialReceiptExpected) {
|
|
3343
|
+
if (!trialReceipt) {
|
|
3344
|
+
if (age > PEER_LIMITS.maxRunMs)
|
|
3345
|
+
this.abandonRemote(entry, 'missing-trial-receipt', { failure: false, cancel: true });
|
|
3346
|
+
continue;
|
|
3347
|
+
}
|
|
3348
|
+
if (trialReceipt.receipt.outcome !== 'completed' || !validTrialReceipt(res.record.smallPeerReceipt, m.attemptId)
|
|
3349
|
+
|| requestDigest(res.record.smallPeerReceipt) !== requestDigest(trialReceipt.receipt)) {
|
|
3350
|
+
this.abandonRemote(entry, 'trial-verdict-receipt-mismatch', { failure: true, cancel: false });
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3086
3354
|
this.clearPeerResultTampered(peer.machineId);
|
|
3087
3355
|
if (res.record.outcome === 'error') {
|
|
3088
3356
|
this.audit({ event: 'peer-record-error', pr: entry.pr, peer: peer.machineId, attemptId: m.attemptId, errorStep: res.record.errorStep });
|
|
@@ -3125,6 +3393,10 @@ export class LocalVerifyService {
|
|
|
3125
3393
|
this.persistQueue();
|
|
3126
3394
|
this.writePeerHold(); // the restart this attempt held need not wait for the next tick
|
|
3127
3395
|
}
|
|
3396
|
+
if (!receiptsChecked)
|
|
3397
|
+
await this.recoverTrialReceipts();
|
|
3398
|
+
if (reserved.length === 0)
|
|
3399
|
+
return;
|
|
3128
3400
|
}
|
|
3129
3401
|
finally {
|
|
3130
3402
|
this.pollRunning = false;
|
|
@@ -3205,8 +3477,10 @@ export class LocalVerifyService {
|
|
|
3205
3477
|
this.writePeerHold();
|
|
3206
3478
|
if (!this.cfg.peerOnly)
|
|
3207
3479
|
this.noteEpisodeProgress(paused);
|
|
3208
|
-
if (this.blockedBy)
|
|
3209
|
-
await this.
|
|
3480
|
+
if (this.blockedBy && await this.reapOrphan() !== 'incomplete') {
|
|
3481
|
+
await reconcileTrialScopes(this.cfg.stateDir);
|
|
3482
|
+
finalizeInterruptedTrials(this.cfg.stateDir, this.cfg.machineId);
|
|
3483
|
+
}
|
|
3210
3484
|
if (this.verifierHold)
|
|
3211
3485
|
this.recheckVerifierHold();
|
|
3212
3486
|
this.checkStarved();
|
|
@@ -4304,7 +4578,7 @@ export class LocalVerifyService {
|
|
|
4304
4578
|
...(entry.kind !== 'main' && this.failFastOn() ? { failFast: true } : {}),
|
|
4305
4579
|
...(entry.kind !== 'main' ? { preflightMode: replay || entry.preflightBypassRetry ? 'off' : this.preflightMode() } : {}),
|
|
4306
4580
|
...(entry.kind !== 'main' ? { preflightRediscoverable: entry.preflightRediscoverable === true } : {}),
|
|
4307
|
-
...(() => { const ls = this.laneShards(); return ls ? { laneShards: ls } : {}; })(),
|
|
4581
|
+
...(() => { const ls = entry.smallPeerTrial ? { unitWorkers: 2, integration: 1, e2e: 1 } : this.laneShards(); return ls ? { laneShards: ls } : {}; })(),
|
|
4308
4582
|
...(entry.kind === 'main' ? { kind: 'main' } : {}),
|
|
4309
4583
|
// Borrowed helpers' baseline results: a `main` verify reports its per-file counts only when someone keeps them
|
|
4310
4584
|
// (a peer run: the coordinator asked; a local run: a helper is configured here or on a peer). Absent otherwise.
|
|
@@ -4334,11 +4608,15 @@ export class LocalVerifyService {
|
|
|
4334
4608
|
const useNice = this.cfg.nice ?? true;
|
|
4335
4609
|
let handle;
|
|
4336
4610
|
try {
|
|
4337
|
-
|
|
4611
|
+
const runArgs = {
|
|
4338
4612
|
command: useNice ? 'nice' : this.cfg.nodePath,
|
|
4339
4613
|
args: useNice ? ['-n', '10', this.cfg.nodePath, ...childArgs] : childArgs,
|
|
4340
4614
|
env: this.cfg.baseEnv, logFile,
|
|
4341
|
-
}
|
|
4615
|
+
};
|
|
4616
|
+
const trial = entry.smallPeerTrial;
|
|
4617
|
+
handle = trial && entry.peerAttempt
|
|
4618
|
+
? spawnSmallPeerSupervisor({ ...runArgs, stateDir: this.cfg.stateDir, attemptId: entry.peerAttempt.id, policy: trial }, () => this.trialPolicyCurrent(trial) && this.peerRoleOn() && !this.stopped)
|
|
4619
|
+
: this.seams.spawnRun(runArgs);
|
|
4342
4620
|
}
|
|
4343
4621
|
catch (e) {
|
|
4344
4622
|
this.clearInFlight();
|
|
@@ -4377,12 +4655,22 @@ export class LocalVerifyService {
|
|
|
4377
4655
|
const cur = this.mainObs.head;
|
|
4378
4656
|
this.mainRunOnCurrentHead = cur !== null && (entry.headSha === cur || this.releaseAlias.get(cur) === entry.headSha) ? entry.headSha : null;
|
|
4379
4657
|
}
|
|
4380
|
-
this.inFlight = { entry, token, pgid: handle.pid, inputPath, resultPath, cancelled: false, startedAt: intent.startedAt,
|
|
4658
|
+
this.inFlight = { entry, token, ...(entry.smallPeerTrial ? { trialHandle: handle, trialExpiresAt: performance.now() + 10_000 } : {}), pgid: handle.pid, inputPath, resultPath, cancelled: false, startedAt: intent.startedAt,
|
|
4381
4659
|
preflightAllowanceMs: input.preflightMode && input.preflightMode !== 'off' ? PREFLIGHT_LIMITS.totalMs : 0,
|
|
4382
4660
|
runInput: input };
|
|
4383
4661
|
this.publishSuitePriority(true);
|
|
4384
4662
|
const mine = this.inFlight;
|
|
4385
|
-
handle.exited.then((x) =>
|
|
4663
|
+
handle.exited.then((x) => {
|
|
4664
|
+
mine.trialCleanupDone = !!entry.smallPeerTrial;
|
|
4665
|
+
this.onExit(mine, x);
|
|
4666
|
+
}, () => {
|
|
4667
|
+
if (entry.smallPeerTrial) {
|
|
4668
|
+
this.audit({ event: 'small-peer-cleanup-unproven', pr: entry.pr, attemptId: entry.peerAttempt?.id });
|
|
4669
|
+
mine.cancelled = true; // Keep the in-flight slot until startup reconciliation proves cleanup.
|
|
4670
|
+
}
|
|
4671
|
+
else
|
|
4672
|
+
this.onExit(mine, { status: null, signal: null });
|
|
4673
|
+
});
|
|
4386
4674
|
this.writeInFlight(intent);
|
|
4387
4675
|
this.persistQueue();
|
|
4388
4676
|
this.audit({ event: 'started', pr: entry.pr, headSha: entry.headSha, baseSha: entry.baseSha, pgid: handle.pid, attempt: entry.attempts,
|
|
@@ -4445,6 +4733,10 @@ export class LocalVerifyService {
|
|
|
4445
4733
|
if (!f || f.cancelled)
|
|
4446
4734
|
return;
|
|
4447
4735
|
f.cancelled = true;
|
|
4736
|
+
if (f.trialHandle) {
|
|
4737
|
+
f.trialHandle.cancelTrial?.(reason);
|
|
4738
|
+
return;
|
|
4739
|
+
}
|
|
4448
4740
|
this.publishSuitePriority(false);
|
|
4449
4741
|
this.audit({ event: 'cancel', pr: f.entry.pr, headSha: f.entry.headSha, reason });
|
|
4450
4742
|
try {
|
|
@@ -4467,7 +4759,7 @@ export class LocalVerifyService {
|
|
|
4467
4759
|
// Handled exactly once: shutdown() settles a run whose result is already on disk, and the
|
|
4468
4760
|
// child's real exit event may still arrive afterwards. Handling it again would find the
|
|
4469
4761
|
// result file gone and record a crash over the real verdict.
|
|
4470
|
-
if (f.settled)
|
|
4762
|
+
if (f.settled || (f.trialHandle && !f.trialCleanupDone))
|
|
4471
4763
|
return;
|
|
4472
4764
|
f.settled = true;
|
|
4473
4765
|
// The verify is over for the borrowed-helper side whatever follows: its attempt token no longer opens the loopback proxy.
|
|
@@ -4496,7 +4788,24 @@ export class LocalVerifyService {
|
|
|
4496
4788
|
}
|
|
4497
4789
|
catch { /* @silent-fallback-ok: the updater's own re-check still runs within 5 minutes */ }
|
|
4498
4790
|
}
|
|
4499
|
-
|
|
4791
|
+
let result = this.readResult(f.resultPath);
|
|
4792
|
+
if (f.entry.smallPeerTrial && f.entry.peerAttempt) {
|
|
4793
|
+
const id = f.entry.peerAttempt.id;
|
|
4794
|
+
let receipt = null;
|
|
4795
|
+
try {
|
|
4796
|
+
receipt = JSON.parse(fs.readFileSync(path.join(trialDirectory(this.cfg.stateDir, id), 'receipt.json'), 'utf8'));
|
|
4797
|
+
}
|
|
4798
|
+
catch (e) {
|
|
4799
|
+
this.audit({ event: 'small-peer-receipt-unreadable', attemptId: id, detail: String(e) });
|
|
4800
|
+
}
|
|
4801
|
+
if (!validTrialReceipt(receipt, id) || receipt.outcome !== 'completed') {
|
|
4802
|
+
result = null;
|
|
4803
|
+
this.beginTrialRecovery(f.entry.smallPeerTrial, receipt?.reserveBreached === true || !receipt || ['measurement-failed', 'setup-failed', 'cleanup-timeout', 'watchdog-lost'].includes(receipt.reason));
|
|
4804
|
+
}
|
|
4805
|
+
this.audit({ event: 'small-peer-receipt', pr: f.entry.pr, headSha: f.entry.headSha, attemptId: id, receipt });
|
|
4806
|
+
if (receipt && result && 'record' in result && result.record)
|
|
4807
|
+
result.record.smallPeerReceipt = receipt;
|
|
4808
|
+
}
|
|
4500
4809
|
if (!f.runInput) {
|
|
4501
4810
|
try {
|
|
4502
4811
|
f.runInput = JSON.parse(fs.readFileSync(f.inputPath, 'utf8'));
|