js-rigor: challenge proofs treat zero timestamps as valid; flake root-caused

The transient full-suite flake (fail 1 in ~5-10% of runs, only visible on
some invocations) was finally captured: challenge-proof's most-recent-proof
property failed once in 800 cases. Root cause: _addChallengeProof built
issuedAt with proof.issuedAt || proof.issued_at || proof.timestamp ||
Date.now() — a generated issuedAt of 0 (epoch) was replaced with the wall
clock, so an epoch-issued proof became the most recent one and the
lookup returned a timestamp (1.7e12) that could never match the
expectation. The same ||-chain corrupted expiresAt: 0 into null, making
epoch-expired proofs never expire. All three chains (issuedAt, expiresAt,
proofId) now use nullish coalescing so zero is a valid timestamp.

Fixed pin added; the challenge-proof file went from ~10% flake to 20/20
clean, and the full suite is stable at 801 tests / 739 pass / 0 fail.
This commit is contained in:
John Dvorak
2026-08-01 22:58:32 -07:00
parent dab9671d20
commit 7c465b64f4
2 changed files with 25 additions and 4 deletions
+6 -3
View File
@@ -120,15 +120,18 @@ export class PartialGraphContext {
_addChallengeProof(proof) {
const subjectId = this._resolveNodeId(proof.subject);
const now = Date.now();
const issuedAt = proof.issuedAt || proof.issued_at || proof.timestamp || now;
const expiresAt = proof.expiresAt || proof.expires_at || null;
// 0 is a valid timestamp (epoch-issued / already-expired); `||` would
// replace it with the wall clock or null, making an epoch-issued proof
// the most recent one and an epoch-expired proof never expire.
const issuedAt = proof.issuedAt ?? proof.issued_at ?? proof.timestamp ?? now;
const expiresAt = proof.expiresAt ?? proof.expires_at ?? null;
const record = {
name: proof.name,
subject: subjectId,
issuedAt,
expiresAt,
source: proof.source || 'partial',
proofId: proof.proofId || proof.proof_id || null,
proofId: proof.proofId ?? proof.proof_id ?? null,
metadata: proof.metadata || null
};
const key = this._challengeKey(record.name, subjectId);