Phase 2: client military/social screens, WebSocket push, trade + endgame, review findings pending

Built: units/movements/reports/send/expansion screens, alliance/messages/rankings screens, ws client + server /ws push
(docs/PROTOCOL.md), Internet exchange trade, backbone endgame + world end, shared reports, buildDone relative levels.
Tested: npm test 175/175. Two adversarial reviews found issues (trade-leg recall exploit, __proto__ via validate.js,
rankings DoS, static headers, ...): fixes follow in the next commit.
NOT done: bots/balance, e2e suite, real-device checks.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-11 19:05:03 +02:00
parent 249818a7aa
commit b18645dca1
87 changed files with 10201 additions and 71 deletions

View file

@ -127,6 +127,7 @@ function dissolve(ctx, allianceId, reason) {
db.run('DELETE FROM alliance_notes WHERE alliance_id = ?', a.id);
const ids = db.all('SELECT operator_id FROM alliance_members WHERE alliance_id = ?', a.id);
for (const m of ids) removeMember(db, m.operator_id);
require('./endgame').onAllianceDissolved(ctx, a.id); // its backbone landing sites are the incumbent's again
db.run('DELETE FROM alliances WHERE id = ?', a.id);
}
@ -172,9 +173,19 @@ const confederated = (db, opA, opB) => { const r = operatorRelation(db, opA, opB
// May not attack each other: same alliance, NAP or confederation.
const pactPartners = (db, opA, opB) => { const r = operatorRelation(db, opA, opB); return r === 'nap' || r === 'confed' || r === 'same_alliance'; };
// Every other operator for whom `confederated(db, operatorId, x)` holds: the rest of the own alliance plus the members of
// alliances in a confederation with it. [] without an alliance.
function confederatedOperators(db, operatorId) {
const me = db.get('SELECT alliance_id FROM operators WHERE id = ?', operatorId);
if (!me || !me.alliance_id) return [];
const ids = [me.alliance_id];
for (const r of db.all("SELECT a_id, b_id FROM alliance_relations WHERE state = 'confed' AND (a_id = ? OR b_id = ?)", me.alliance_id, me.alliance_id)) ids.push(r.a_id === me.alliance_id ? r.b_id : r.a_id);
return db.all('SELECT id FROM operators WHERE alliance_id IN (' + ids.map(() => '?').join(',') + ') AND id != ? ORDER BY id', ...ids, operatorId).map((r) => r.id);
}
module.exports = {
S, HOUR, operatorOf, peeringLevel, membership, getAlliance, memberCount, leaderOf, allianceBrief, effectiveCap, refreshCap,
addMember, removeMember, requireRole, userOfOperator, notifyOperator, notifyAlliance, dissolve,
pairOf, getRelation, setRelation, withdrawProposals,
relationBetween, operatorRelation, atWar, confederated, pactPartners,
relationBetween, operatorRelation, atWar, confederated, pactPartners, confederatedOperators,
};