ad4m
ad4m copied to clipboard
SocialOrganism MVP implementation
The core benefit of the Social Organism implementation is for Expressions (of any Language - we will mostly use it for LinkExpressions I guess) to be spoken on behalf of a Social Organism. Since there is no intermediary nor objective DB/back-end/smart-contract executing the Social Organism as an entity, expressions of the SO can only be created by member agents. So Expressions that the SO creates need to be authored by some agent speaking on behalf of the SO.
The main question and problem to solve is this: "Is this expression that is claimed to be an expression of the SO actually in coherence with the (internal/private) state of the SO and its Social DNA?"
SO Expressions
With the SO implementation in AD4M, there should be an automatic process within AD4M that:
- Flags an Expression as something a particular SO says
- Shows (to any agent, especially those outside of the SO) if that expression is coherent
For that we add two fields to the generic Expression class:
socialOrganismSource?: string
to ExpressionClass
itself, which just signals that this Expression (though authored by an atomic agent) is spoken on behalf of the given Social Organism - if this field is not null.
And second:
socialOrganismCoherence?: number
which gets added to ExpressionProof
and is, similar to valid
/invalid
, a virtual property that the AD4M executor calculates and adds to the response sent to clients/UIs.
The number is understood as a percentage with 0 meaning not coherent (yet) at all and 1 meaning 100% coherent.
SO Coherence
What does this number mean? What is SO coherence?
When an SO Expression gets created, which means, somebody claims to speak on behalf of the whole, all other agents in this SO will get notified by that event, ultimately executed by the agent creating the expression since they want to get their expression to reach a high coherence number soon. When those other members get notified of a new SO Expression, they will retrieve that Expression and check if it is something the SO is allowed to say by running the Organisms Social DNA action on it. If that Social DNA action/query returns true, they will add their signature to that Expression.
So ultimately, the Expression's SO-coherence-number is just the ratio of member agents that have signed the Expression. (number of signatures) / (number of member agents in the SO)
SO Bootstrap Language
To make this work, we add another bootstrap Language for Social Organisms, which
- stores expressions that represent SOs, similar to the Neighbourhood language. Installing it in AD4M with an alias introduces an SO schema for global addressing of SOs:
so://<hash based unique address>
- stores the member signatures of Expressions spoken on behalf of SOs
For the latter, we introduce a new Language interface:
export interface SocialOrganismAdapter {
create(organismAddress: string, messageURI: string)
concur(organismAddress: string, messageURI: string)
reject(organismAddress: string, messageURI: string)
signatures(organismAddress: string, messageURI: string): Promise<string[]>
members(organismAddress: string): Promise<string[]>
vouchForNewMember(organismAddress: string, newMemberDid: string)
rejectNewMember(organismAddress: string, newMemberDid: string)
newExpressionCallback()
newMemberCallback()
}
SO Social DNA actions
We need to define a Social DNA / Prolog interface (prediactes) which needs to be implemented by a SO's Social DNA:
- Output Expression predicate (taking in an Expression claimed to be spoken on behalf of the SO - true if something the SO is allowed to say)
- Membrane / member change (taking in a DID, return true if that agent shall be added to the member list)
These Social DNA predicates will be queried automatically by the executor to implement the described process.
UI/Client functions
We need a new section in Ad4mClient
for social organisms with the following functions:
let soURI = await ad4m.so.create(socialOrganism: SocialOrganismInput): string // returns URI so://Qm343w5r3
await ad4m.so.speak(soURI, new Link({source: ...}), <language address>)
//using above functions with Links needs the planned, but currently not yet implemented, global link addresses (i.e. our LinkLanguage implementing the ExpressionAdapter
let soMembers = await ad4m.so.members(soURI)
await ad4m.so.suggestMemberAddition(soURI, newMemberDID)
await ad4m.so.suggestMemberRemoval(soURI, memberDID)