feat(events): send the idempotency key, and declare champ.boss.killed (Phase 11a)
The website's half of protocol 6. Every event-driven write now carries the step's idempotency key, and `uo.broadcast` stops being un-retryable. Phase 9 shipped it answering `retry: false` to everything including a 503 from a shard that was merely restarting, with a comment naming the line that would change when the wire could refuse a repeat. This is that line: it defers to `sidecarFailure`, the same helper its two siblings already used, so the hand-rolled variant that forced every outcome terminal is gone rather than re-tuned. One verb was less idempotent than its own id made it look. Both keyed verbs post under a run-scoped id and a repeat replaces — but `news.add` with `announce: true` makes the criers proclaim the title on every post, so a retry replaced the article silently and proclaimed it again. The key stops the second proclamation. `champ.boss.killed` is mapped to the `champs` feature (rule 2 would otherwise fail it closed to admin), with `damagers` a nested `staff` field rule: the kill is public because a champion falling is what the board is for, the ranked roll of who was strong enough to fell it is not. `uo.champ.boss_killed` is declared as a trigger — which is what makes it usable as an event PHASE CONDITION, since a condition is written over a trigger firing — and it carries `damagerCount`, never a damager name, because a trigger variable reaches mail an operator may address to every subscriber. Its seeded rule is its own group, `champ-boss-killed-v1`: `triggers-v1` is stamped once under a settings guard, so appending a 27th entry would have reached fresh installs and nothing else. It also ships email+inapp and NOT push, and the comment says why — no trigger in this module is also a registered stream, so no engagement rule here can push. That is pre-existing in twenty rules and flagged rather than fixed; this one declines to be the twenty-first. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,58 @@ test('an unknown viewer level cannot see a gated kind or a locked field', async
|
||||
assert.equal('webId' in out.leader, false)
|
||||
})
|
||||
|
||||
// ── Protocol 6: the champion defeat ──────────────────────────────────
|
||||
|
||||
const KILL = {
|
||||
kind: 'champ.boss.killed',
|
||||
serial: '0x40012345',
|
||||
boss: 'Semidar',
|
||||
killer: { serial: '0x55', name: 'Aldric', acct: 'seed_002', player: true },
|
||||
damagers: [
|
||||
{ serial: '0x55', name: 'Aldric', acct: 'seed_002', webId: '7', player: true, damage: 900 },
|
||||
{ serial: '0x56', name: 'Bran', acct: 'seed_003', player: true, damage: 120 },
|
||||
],
|
||||
}
|
||||
|
||||
test('the kill is public and its damage table is not', () => {
|
||||
const config = visibility.compileDefaults()
|
||||
// The whole shape of this addition in one assertion: a champion falling is
|
||||
// content the public board is FOR, and a ranked roll of who was strong enough
|
||||
// to fell it is a performance record nobody published on purpose.
|
||||
assert.equal(visibility.kindVisibleTo('champ.boss.killed', 'anonymous', config), true)
|
||||
for (const level of ['anonymous', 'logged_in', 'player']) {
|
||||
const out = visibility.projectFeature('champs', KILL, level, config)
|
||||
assert.equal(out.boss, 'Semidar', `${level} sees which boss fell`)
|
||||
assert.equal('damagers' in out, false, `${level} must not see the damage table`)
|
||||
}
|
||||
assert.equal(visibility.projectFeature('champs', KILL, 'staff', config).damagers.length, 2)
|
||||
})
|
||||
|
||||
test('the killer rides the frame the way mob.killed already publishes one', () => {
|
||||
// Deliberately NOT a configurable field. It is one actor, announced in-game to
|
||||
// everyone present, and the same disclosure the public activity feed has made
|
||||
// through `mob.killed` since before this framework existed.
|
||||
const config = visibility.compileDefaults()
|
||||
const out = visibility.projectFeature('champs', KILL, 'anonymous', config)
|
||||
assert.equal(out.killer.name, 'Aldric')
|
||||
assert.equal('acct' in out.killer, false, 'rule 1 still applies inside it')
|
||||
})
|
||||
|
||||
test('an admin who lowers the damager rule still cannot see an account inside it', () => {
|
||||
// Rule 1 beats a field rule wherever the two meet, and a damager entry is an
|
||||
// actor object like any other. An admin who opens the table to everyone has
|
||||
// published character names, which is what they chose; they have not published
|
||||
// account names, which is not theirs to choose.
|
||||
const config = visibility.compileDefaults()
|
||||
config.champs.fields = { ...config.champs.fields, damagers: 'anonymous' }
|
||||
const out = visibility.projectFeature('champs', KILL, 'anonymous', config)
|
||||
assert.equal(out.damagers.length, 2)
|
||||
assert.equal(out.damagers[0].name, 'Aldric')
|
||||
assert.equal(out.damagers[0].damage, 900)
|
||||
assert.equal('acct' in out.damagers[0], false)
|
||||
assert.equal('webId' in out.damagers[0], false)
|
||||
})
|
||||
|
||||
// ── Rule 1: locked fields ──────────────────────────────────────────────────
|
||||
|
||||
test('acct and webId are stripped below admin regardless of feature config', () => {
|
||||
@@ -360,10 +412,21 @@ const V3_ADDED_PUBLIC_KINDS = ['world.ruleset', 'points.board']
|
||||
// inside the roster's member array (see the roster test above).
|
||||
const V4_ADDED_PUBLIC_KINDS = ['guild.roster', 'guild.leave']
|
||||
|
||||
test('derived PUBLIC_KINDS is exactly the pre-v3 allowlist plus the v3 and v4 additions', () => {
|
||||
// v6 adds the champion defeat. It rides the existing `champs` feature, which is
|
||||
// already anonymous, so the KIND is public — while the `damagers` table on it is
|
||||
// `staff` by field rule. That split is the point: a shard announces that its
|
||||
// champion fell without publishing a roll of who was strong enough to fell it.
|
||||
const V6_ADDED_PUBLIC_KINDS = ['champ.boss.killed']
|
||||
|
||||
test('derived PUBLIC_KINDS is exactly the pre-v3 allowlist plus the v3, v4 and v6 additions', () => {
|
||||
assert.deepEqual(
|
||||
[...visibility.PUBLIC_KINDS].sort(),
|
||||
[...PRE_V3_PUBLIC_KINDS, ...V3_ADDED_PUBLIC_KINDS, ...V4_ADDED_PUBLIC_KINDS].sort(),
|
||||
[
|
||||
...PRE_V3_PUBLIC_KINDS,
|
||||
...V3_ADDED_PUBLIC_KINDS,
|
||||
...V4_ADDED_PUBLIC_KINDS,
|
||||
...V6_ADDED_PUBLIC_KINDS,
|
||||
].sort(),
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user