source: Klonkt/test/has-guardians.test.js@ 23da947

main
Last change on this file since 23da947 was af5b79b, checked in by Robin <roboburr@…>, 7 weeks ago

FEP-633c §2.2: shaer:hasGuardians (outbound stempelen, inbound registreren)

Objecten van een ward krijgen nu de advies-hint shaer:hasGuardians, zodat een
remote server interacties met de post naar de guardians kan routen zonder eerst
de actor op te halen. Veilig te negeren door wie geen shaer spreekt.

Outbound: elke Note die een ward publiceert wordt gestempeld (alle drie de
buildNote-paden: gewone post, paid-teaser, reply/direct), dus ook via buildCreate
in de outbox. Inbound: de hint wordt alleen GEREGISTREERD op het opgeslagen object
(ap_timeline.has_guardians / ap_mentions.has_guardians), nog geen actie. Wordt
later bekendgemaakt bij reddings-boei / escalatie-routing (Robins besluit).

Changed files:
src/services/guardianship/notes.js

  • hasGuardiansProps(slug) (stempel als de site guardians heeft) + objectHasGuardians(o)

src/services/guardianship/index.js

  • beide geexporteerd

src/services/ActivityPubService.js

  • buildNote stempelt in alle drie de return-paden; inbound zet has_guardians op timeline + mention

src/config/database.js

  • ap_timeline.has_guardians + ap_mentions.has_guardians

test/has-guardians.test.js

  • ward stempelt wel, free niet; objectHasGuardians leest de hint

remarks: npm test 170/170. Alleen ward-objecten dragen de hint; niks acteert er nog
op (register-only). Daemon heeft de constante al (dead_code); wiren kan later.

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

  • Property mode set to 100644
File size: 1.3 KB
Line 
1// FEP-633c §2.2: shaer:hasGuardians object hint (outbound stamp + register).
2import { test } from 'node:test';
3import assert from 'node:assert/strict';
4
5process.env.DATABASE_PATH = ':memory:';
6process.env.PUBLIC_BASE_URL = 'https://test.example';
7
8const dbMod = await import('../src/config/database.js');
9const db = dbMod.default;
10dbMod.initializeDatabase();
11const G = await import('../src/services/guardianship/index.js');
12
13db.prepare('INSERT INTO users (id, username, email, password_hash, role) VALUES (?,?,?,?,?)').run('u1','u1','u1@t','x','god');
14db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,1)').run('s1','kid','kid','u1');
15db.prepare('INSERT INTO sites (id, slug, title, owner_id, is_primary) VALUES (?,?,?,?,0)').run('s2','free','free','u1');
16db.prepare("INSERT INTO ap_guardianships (slug, role, other_uri, status, created_at) VALUES ('kid','ward','https://m.example/mom','accepted',CURRENT_TIMESTAMP)").run();
17
18test('a ward stamps the hint; a free actor does not', () => {
19 assert.deepEqual(G.hasGuardiansProps('kid'), { 'shaer:hasGuardians': true });
20 assert.deepEqual(G.hasGuardiansProps('free'), {});
21});
22
23test('objectHasGuardians reads the hint, register-only', () => {
24 assert.equal(G.objectHasGuardians({ 'shaer:hasGuardians': true }), true);
25 assert.equal(G.objectHasGuardians({}), false);
26});
Note: See TracBrowser for help on using the repository browser.