chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
The e2e world's index wait passes on any day
harness/shots/world.mjs+33−11
| @@ -417,21 +417,23 @@ export async function create() { | ||
`${net.pds}/xrpc/com.atproto.repo.listRecords?repo=${did}&collection=${collection}&limit=100${cursor}`, | ||
).then((r) => r.json()) | ||
for (const r of listed.records) { | ||
if (typeof r.value.createdAt === 'string') records.push({ ...r, who, did, collection, jwt: session.accessJwt }) | ||
if (typeof r.value.createdAt === 'string' && collection !== 'dev.knotless.ref') records.push({ ...r, who, did, collection, jwt: session.accessJwt }) | ||
} | ||
cursor = listed.cursor ? `&cursor=${listed.cursor}` : '' | ||
} while (cursor) | ||
} | ||
} | ||
// A new ref's push is its record's first version, which has no | ||
// createdAt to stamp: the index keeps it as a push under the key its | ||
// claim would have had (`<ref key>.0`), at the time it was made. Each | ||
// takes its place among the records as that claim would, and its | ||
// stamp is written into the index rather than the PDS. | ||
// A new ref's push is its record's first version, which no claim | ||
// records: the index keeps it as a push with nothing before it, under | ||
// the key a claim on the generation before would have had, at the | ||
// time it was made. Each takes its place among the records as that | ||
// claim would, and its stamp is written into the index rather than the | ||
// PDS. The ref records themselves keep the times they were pushed at, | ||
// which no page shows. | ||
const index = new DatabaseSync(join(dir, 'index.db')) | ||
index.exec('PRAGMA busy_timeout = 10000') | ||
const who = Object.fromEntries(Object.entries(account).map(([name, a]) => [a.did, name])) | ||
for (const p of index.prepare("SELECT uri, did, created_at FROM push WHERE uri LIKE '%.0'").all()) { | ||
for (const p of index.prepare("SELECT uri, did, created_at FROM push WHERE before IS NULL").all()) { | ||
records.push({ uri: p.uri, who: who[p.did], did: p.did, collection: 'dev.knotless.claim', value: { createdAt: p.created_at }, pushed: true }) | ||
} | ||
// One write's records can be stamped a millisecond apart or in the same | ||
| @@ -800,12 +802,32 @@ export async function create() { | ||
// out, as on that day it is today's. | ||
const day = (t) => new Date(t).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' }) | ||
const today = day(Date.now()) | ||
await until('the index', async () => { | ||
// What still holds the wait back, said if it times out. | ||
let missing = [] | ||
const shown = ['Merged as', 'Closed by', '2 Closed', 'Forked from', '1 Closed', '2/2', 'prints_json', 'In a batch of 2 being checked', 'Landed', 'Runs only when asked', 'tally-server', 'Pre-release'] | ||
const caughtUp = async () => { | ||
const names = Object.keys(views) | ||
const pages = await Promise.all(Object.values(views).map(page)) | ||
const all = pages.join('') | ||
return !all.replaceAll(day(freeing), '').includes(today) && all.includes('Merged as') && all.includes('Closed by') && all.includes('2 Closed') && all.includes('Forked from') && all.includes('1 Closed') && all.includes('2/2') && (all.includes('Some checks failed') || all.includes('Some checks were not successful')) && all.includes('prints_json') && all.includes('In a batch of 2 being checked') && /Ejected <time/.test(all) && all.includes('Landed') && all.includes('Runs only when asked') && all.includes('tally-server') && all.includes('Pre-release') | ||
&& (await page('/bob.test')).includes('textkit.test') && (await page(views['org-members'])).includes('bob.test') | ||
}) | ||
const dated = names.filter((_, i) => pages[i].replaceAll(day(freeing), '').includes(today)) | ||
missing = [ | ||
...dated.map((v) => { | ||
const at = pages[names.indexOf(v)].replaceAll(day(freeing), '').indexOf(today) | ||
return `today's date on ${v}: ${JSON.stringify(pages[names.indexOf(v)].slice(Math.max(0, at - 160), at + 40))}` | ||
}), | ||
...shown.filter((t) => !all.includes(t)), | ||
...(all.includes('Some checks failed') || all.includes('Some checks were not successful') ? [] : ['Some checks failed']), | ||
...(/Ejected <time/.test(all) ? [] : ['Ejected <time']), | ||
...((await page('/bob.test')).includes('textkit.test') ? [] : ['textkit.test on /bob.test']), | ||
...((await page(views['org-members'])).includes('bob.test') ? [] : ['bob.test on org-members']), | ||
] | ||
return missing.length === 0 | ||
} | ||
try { | ||
await until('the index', caughtUp) | ||
} catch (e) { | ||
throw new Error(`${e.message}, still missing: ${missing.join('; ')}`) | ||
} | ||
return { net, dir, views, cards, pds, server: children[1], stop } | ||
} catch (e) { | ||
stop() | ||