Phase 842: 4-peer guild offline recovery mesh fanout (v0.8.809)
Add runGuildMeshQuadOfflineRecoveryJourney and meshQuadOfflineRecoveryReady matcher for quad disconnect/reconnect with offline recovery on all guests. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
Agent control plane for Pearcord — send the same IPC messages the UI sends, read `view` snapshots, and run scripted journeys against a **live worker** or an in-process **headless** session.
|
Agent control plane for Pearcord — send the same IPC messages the UI sends, read `view` snapshots, and run scripted journeys against a **live worker** or an in-process **headless** session.
|
||||||
|
|
||||||
|
**Phase 842 (v0.8.809):** `runGuildMeshQuadOfflineRecoveryJourney` (4-peer offline recovery). Bundle: `npm run test:ci-phase842`.
|
||||||
|
|
||||||
**Phase 841 (v0.8.808):** `runGuildMeshQuadSyncHealthJourney` (4-peer sync health rail). Bundle: `npm run test:ci-phase841`.
|
**Phase 841 (v0.8.808):** `runGuildMeshQuadSyncHealthJourney` (4-peer sync health rail). Bundle: `npm run test:ci-phase841`.
|
||||||
|
|
||||||
**Phase 840 (v0.8.807):** `runGuildMeshQuadSyncPendingJourney` (4-peer sync pending & outbox). Bundle: `npm run test:ci-phase840`.
|
**Phase 840 (v0.8.807):** `runGuildMeshQuadSyncPendingJourney` (4-peer sync pending & outbox). Bundle: `npm run test:ci-phase840`.
|
||||||
|
|||||||
@@ -201,6 +201,16 @@ function matchView (view, spec) {
|
|||||||
if (!gid || !rail || typeof rail !== 'object') return false
|
if (!gid || !rail || typeof rail !== 'object') return false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if (key === 'meshQuadOfflineRecoveryReady') {
|
||||||
|
if (!expected) return true
|
||||||
|
const peers = Number(view?.stats?.peers) || 0
|
||||||
|
if (peers < 2) return false
|
||||||
|
const gid = view?.guild?.id
|
||||||
|
const rail = gid ? view.guildSyncHealthRail?.[gid] : null
|
||||||
|
if (rail?.meshBounded) return false
|
||||||
|
if (view?.meshStabilityStats?.pushHalted) return false
|
||||||
|
continue
|
||||||
|
}
|
||||||
if (key === 'meshQuadUnreadReady') {
|
if (key === 'meshQuadUnreadReady') {
|
||||||
if (!expected) return true
|
if (!expected) return true
|
||||||
const peers = Number(view?.stats?.peers) || 0
|
const peers = Number(view?.stats?.peers) || 0
|
||||||
|
|||||||
+108
@@ -8215,6 +8215,114 @@ class HeadlessSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Phase 842: 4-peer mesh — offline recovery on host + all three guests after reconnect. */
|
||||||
|
async runGuildMeshQuadOfflineRecoveryJourney () {
|
||||||
|
const {
|
||||||
|
connectGuildMeshQuad,
|
||||||
|
disconnectGuildMeshQuad
|
||||||
|
} = require('./mesh-helpers')
|
||||||
|
const token = `offline842-${Date.now()}`
|
||||||
|
const base = path.join(os.tmpdir(), `pearcord-agentctl-offline842-${Date.now()}`)
|
||||||
|
const host = new HeadlessSession({ storagePath: path.join(base, 'host') })
|
||||||
|
const guest1 = new HeadlessSession({ storagePath: path.join(base, 'guest1') })
|
||||||
|
const guest2 = new HeadlessSession({ storagePath: path.join(base, 'guest2') })
|
||||||
|
const guest3 = new HeadlessSession({ storagePath: path.join(base, 'guest3') })
|
||||||
|
await host.start()
|
||||||
|
await guest1.start()
|
||||||
|
await guest2.start()
|
||||||
|
await guest3.start()
|
||||||
|
try {
|
||||||
|
await host.registerUser({ username: 'offhost842', displayName: 'Offline Host 842' })
|
||||||
|
await host.createGuild({ name: 'Offline Quad 842', publicListing: false })
|
||||||
|
await host.wait({ mode: 'guild' }, 45000)
|
||||||
|
const invite = await host.platform.createInvite().catch(() => null)
|
||||||
|
const code = invite?.shareCode || invite?.code
|
||||||
|
if (!code) throw new Error('host invite missing')
|
||||||
|
await guest1.registerUser({ username: 'offguest842a', displayName: 'Offline Guest 842a' })
|
||||||
|
await guest2.registerUser({ username: 'offguest842b', displayName: 'Offline Guest 842b' })
|
||||||
|
await guest3.registerUser({ username: 'offguest842c', displayName: 'Offline Guest 842c' })
|
||||||
|
await guest1.ipc({ type: 'join-invite', code })
|
||||||
|
await guest2.ipc({ type: 'join-invite', code })
|
||||||
|
await guest3.ipc({ type: 'join-invite', code })
|
||||||
|
await guest1.wait({ mode: 'guild' }, 45000)
|
||||||
|
await guest2.wait({ mode: 'guild' }, 45000)
|
||||||
|
await guest3.wait({ mode: 'guild' }, 45000)
|
||||||
|
const chId = (await host.refreshView()).activeChannelId
|
||||||
|
if (!chId) throw new Error('active channel missing')
|
||||||
|
for (const sess of [guest1, guest2, guest3]) {
|
||||||
|
await sess.ipc({ type: 'select-channel', channelId: chId })
|
||||||
|
await sess.wait({ activeChannelId: chId }, 30000)
|
||||||
|
}
|
||||||
|
await connectGuildMeshQuad(
|
||||||
|
host.platform,
|
||||||
|
guest1.platform,
|
||||||
|
guest2.platform,
|
||||||
|
guest3.platform,
|
||||||
|
55000
|
||||||
|
)
|
||||||
|
const quadWait = { meshQuadReady: true, membersMin: 4 }
|
||||||
|
await host.wait(quadWait, 30000)
|
||||||
|
await guest1.wait(quadWait, 30000)
|
||||||
|
await guest2.wait(quadWait, 30000)
|
||||||
|
await guest3.wait(quadWait, 30000)
|
||||||
|
await host.sendGuildMessage(token)
|
||||||
|
const msgWait = { activeChannelMessageIncludes: token }
|
||||||
|
await guest1.wait(msgWait, 90000)
|
||||||
|
await guest2.wait(msgWait, 90000)
|
||||||
|
await guest3.wait(msgWait, 90000)
|
||||||
|
await disconnectGuildMeshQuad(
|
||||||
|
host.platform,
|
||||||
|
guest1.platform,
|
||||||
|
guest2.platform,
|
||||||
|
guest3.platform,
|
||||||
|
20000
|
||||||
|
)
|
||||||
|
for (const sess of [guest1, guest2, guest3]) {
|
||||||
|
await sess.wait({ meshPeersExact: 0 }, 30000)
|
||||||
|
}
|
||||||
|
await connectGuildMeshQuad(
|
||||||
|
host.platform,
|
||||||
|
guest1.platform,
|
||||||
|
guest2.platform,
|
||||||
|
guest3.platform,
|
||||||
|
55000
|
||||||
|
)
|
||||||
|
for (const p of [host.platform, guest1.platform, guest2.platform, guest3.platform]) {
|
||||||
|
if (typeof p.runOfflineRecoverySync === 'function') {
|
||||||
|
await p.runOfflineRecoverySync().catch(() => null)
|
||||||
|
}
|
||||||
|
if (typeof p.requestGuildSyncFanout === 'function') {
|
||||||
|
p.requestGuildSyncFanout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const readyWait = {
|
||||||
|
meshQuadOfflineRecoveryReady: true,
|
||||||
|
meshReconnectReady: true,
|
||||||
|
meshPeersMin: 2
|
||||||
|
}
|
||||||
|
await host.wait(readyWait, 90000)
|
||||||
|
await guest1.wait(readyWait, 90000)
|
||||||
|
await guest2.wait(readyWait, 90000)
|
||||||
|
await guest3.wait(readyWait, 90000)
|
||||||
|
await guest1.wait(msgWait, 90000)
|
||||||
|
await guest2.wait(msgWait, 90000)
|
||||||
|
await guest3.wait(msgWait, 90000)
|
||||||
|
const hv = await host.refreshView()
|
||||||
|
const g3v = await guest3.refreshView()
|
||||||
|
return {
|
||||||
|
token,
|
||||||
|
hostPeers: hv.stats?.peers,
|
||||||
|
guest3Peers: g3v.stats?.peers,
|
||||||
|
guest3Bounded: g3v.guildSyncHealthRail?.[g3v.guild?.id]?.meshBounded
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await host.close()
|
||||||
|
await guest1.close()
|
||||||
|
await guest2.close()
|
||||||
|
await guest3.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Phase 829: 4-peer mesh — drop one guest, survivors stay synced, rejoin + recovery burst. */
|
/** Phase 829: 4-peer mesh — drop one guest, survivors stay synced, rejoin + recovery burst. */
|
||||||
async runGuildMeshQuadChurnRejoinJourney () {
|
async runGuildMeshQuadChurnRejoinJourney () {
|
||||||
const {
|
const {
|
||||||
|
|||||||
Reference in New Issue
Block a user