code wiki / (root) / nx_chatmut.nx

nx_chatmut.nx source

↩ module page · 31 lines · 2179 B

1// nx_chatmut.nx -- sovereign POLITE, TRANSPARENT message mutation for an S-class chat that helps relationships stay 2// positive (operator: "retract not just delete; don't leave a delete sitting in chat; no sneakiness"). The model is 3// honest BY CONSTRUCTION: 4// * RETRACT removes the message CONTENT (it isn't left sitting in the thread) but leaves a visible "retracted" 5// tombstone -- the other person is never confused or silently deceived (the opposite of a stealth delete). 6// * EDIT keeps the message but marks it "edited" and counts the edits (no hidden silent rewrites = no gaslighting). 7// * a retracted message is terminal: it can't be quietly resurrected or re-edited. 8// Message record rec[*i64]: [0]=mut_state, [1]=edit_count, [2]=content_len. Rides E2E (nx_e2e). license_tier: ORIGINAL 9 10const CMT_LIVE: i64 = 0 // normal, no marker 11const CMT_EDITED: i64 = 1 // visibly "edited" 12const CMT_RETRACTED: i64 = 2 // visible "message retracted" tombstone; content gone 13 14func cmt_init(rec: *i64, content_len: i64) -> i64 { rec[0] = CMT_LIVE; rec[1] = 0; rec[2] = content_len; return 0 } 15// edit the message: marks it edited + bumps the edit count (transparent history). No-op if already retracted. 16func cmt_edit(rec: *i64, new_len: i64) -> i64 { 17 if rec[0] == CMT_RETRACTED { return 0 } // can't sneakily edit a retracted message 18 rec[0] = CMT_EDITED 19 rec[1] = rec[1] + 1 20 rec[2] = new_len 21 return 1 22} 23// retract (polite unsend): clear the content (not left sitting) but leave the transparent tombstone. 24func cmt_retract(rec: *i64) -> i64 { rec[0] = CMT_RETRACTED; rec[2] = 0; return 1 } 25// the marker the OTHER person always sees: 0 none / 1 edited / 2 retracted. Equals the state by construction. 26func cmt_marker(rec: *i64) -> i64 { return rec[0] } 27// transparency invariant: if the message was mutated at all, a marker is shown (the recipient is never deceived). 28func cmt_is_honest(rec: *i64) -> i64 { 29 if rec[0] == CMT_LIVE { if rec[1] == 0 { return 1 } return 0 } // LIVE must mean truly unedited 30 return 1 // EDITED/RETRACTED always carry their marker 31}