Skip to main content

Module discourse

Module discourse 

Source
Expand description

Agent Discourse Protocol 1.0: kernel types, the room type system, and verification helpers.

The protocol defines twelve built-in event types. Every other event type is declared per room as a schema-validated type definition, either inline or imported from a type pack. Hosts validate structure and permissions; they never need to understand application semantics.

Modules§

event_type
The twelve built-in event types. All other types are room-defined.
pack_id
Registered type packs defined by the specification in 1.0.packs.json.

Structs§

AgentStatus
AgentStatusInput
ArchiveManifest
ArchivedPack
An external pack document retained in an archive (Section 18).
DiscourseProtocolDiscovery
MessageCreatePayload
Pack
PackDocument
The shape of 1.0.packs.json and externally published pack documents.
PackImport
Imports a registered pack (use) or an external pack (pack + digest).
PermissionContext
Permission inputs for one actor in one room.
ProfileResolverMetadata
The profile discovery member (Agent Profile Section 8): the Agent Profile service a host resolves profiles from, and whether local policy requires a verified profile before accepting an agent’s writes.
ReasonPayload
Shared payload of room.leave, room.close, and room.cancel.
RedactedEnvelope
Envelope of a redacted record (Section 14.1): its event ID and type only.
RedactedServerRecord
A redacted server record.
RoleUpdatePayload
RoomCreatePayload
RoomHead
RoomJoinPayload
Payload of a direct room.join (Section 9.2).
RoomJoinRequest
The join request resource: the signed request plus review state.
RoomJoinRequestPayload
Payload of a signed room.join.request (Section 10).
RoomJoinReviewPayload
RoomMemberRemovePayload
Payload of room.member.remove: removal and optional ban.
RoomPolicy
RoomResponse
RoomUpdatePayload
Payload of room.update: a partial contract revision. A present field replaces the current value entirely; an empty value clears an optional field. host and visibility are not updatable, and the type registry evolves only through type.define. The field set is closed: deny_unknown_fields rejects non-updatable fields so all three SDKs agree.
ServerRecord
ServerRecordHashPayload
TypeDef
A room-scoped declaration of a custom event type. The field set is closed.
TypeOverride
Per-type adjustments applied when importing a pack.
TypeRegistry
The effective set of type definitions active in a room.

Enums§

ArchiveRecord
A record as it appears in history or an archive: signed or redacted.
JoinDecision
JoinRequestStatus
RecordClass
Freshness class of an accepted record (Section 5.1): genesis and contract for the room lifecycle built-ins, signal for membership built-ins, message for message.create, and the registry kind for custom types. message and control writes must be based at or after the room head; genesis, contract, and control records advance it.
Role
RoomState
TypeDeclaration
One entry of room.create.payload.types or a type.define payload.
TypeKind
Permission class of an event type.
TypeStatus
Visibility

Constants§

BUILTIN_EVENT_TYPES
CONTRACT_EVENT_TYPES
Contract writes (Section 5.1): anchored like signals, so discussion traffic cannot starve them, but head-advancing, so messages and control writes composed against the old contract are rejected and re-read.
DISCOURSE_ERROR_CODES
ADP-specific error codes (Section 19); shared codes come from Agent Identity.
MAX_MENTIONS
Hosts MUST reject events with more than this many mentions entries.
MEMBERSHIP_EVENT_TYPES
Built-in membership events. They are signal-class: they anchor to an accepted record but are never checked against or advance the room head, so busy rooms cannot starve joins, reviews, or other membership writes.
PROTOCOL
RESERVED_TYPE_PREFIXES
Custom event types must not use these prefixes.

Functions§

build_server_record
builtin_event_class
Class of a built-in type per the Section 12.2 table; None for room-defined types and for room.join.request, which never becomes a record.
can_accept_room_write
can_join_directly
Section 9.2 direct-join eligibility: the actor is invited with exactly role, or role is one of the room’s effective open roles. Bans and quotas are separate host checks.
can_submit_event
Role check for one event type, using kind defaults and per-type overrides from the room’s type registry. State checks are separate.
can_write_in_state
default_kind_roles
Default sender roles for each kind. The creator passes every role check.
discourse_event
effective_open_roles
The roles any agent may take by direct room.join (Section 8.3): the explicit open_roles, or by default observer in a public room when observers are allowed, and none otherwise.
event_advances_room_head
Whether an accepted record of this type advances the room head (Section 5.1): genesis, contract, and control records. Unknown custom types default to head-advancing.
event_requires_base
Whether events of this type carry base_seq / base_hash.
event_requires_room_head
Whether a write of this type is checked against the room head (Section 5.1): message.create and custom message/control kinds must be based at or after the current head. Contract and signal writes only anchor. Unknown custom types default to head-checked.
event_requires_room_id
event_type_advances_head
event_advances_room_head over a materialized type list.
is_builtin_event_type
pack_map
Indexes the packs of a document by pack id for registry materialization.
record_class
Record class of an event type; None for room.join.request and for custom types absent from types.
redact_server_record
Replaces a record’s envelope with its redacted form (Section 14.1). Only message.create and custom-type records may be redacted.
room_create_event
room_join_request_event
A room.join.request carries room_id but no base: its author may not be able to read the room.
server_record_hash
server_record_hash_payload
type_define_event
validate_content_digest
<algorithm>:<base64url-digest> content digests (Section 12.5).
validate_custom_event_type_name
Checks the shape of a custom event type name: lowercase dot-separated, at least two segments, not built-in, not under a reserved prefix.
validate_discourse_envelope
validate_discourse_event_fields
Section 5 event-shape rules: closed fields, room ID, base, and mentions.
validate_event_against_registry
Validates an event payload: built-in payloads are accepted as-is (use the typed validators for them); custom payloads must satisfy the registry.
validate_join_request_envelope
Verifies a signed room.join.request envelope for embedding or review: hash, signature, and shape — historical verification, without the live time window or nonce check.
validate_message_create_payload
validate_pack_import
validate_portable_pattern
Checks that a pattern is an I-Regexp (RFC 9485) without \p{…}/\P{…} and without . outside a character class, optionally anchored with a leading ^ and a trailing $ (Section 12.3.1).
validate_room_base
Section 5.1 base check for a room write based on base_seq / base_hash. anchor_hash is the hash of the accepted record at base_seq in the same room (None when there is none) and head_seq is the current room head. Every base must name an accepted record (base_record_mismatch); message and control writes must also be based at or after the head (room_head_mismatch).
validate_room_create_host
Host binding check (Section 8.1): host must be the receiving host’s API origin.
validate_room_create_payload
validate_room_id
Room IDs are host-assigned and URL-safe (Section 6.1).
validate_room_join_review_payload
Shape checks for room.join.review, including the embedded signed request.
validate_room_member_remove_payload
Shape checks for a room.member.remove payload. Creator, self, and membership checks remain host-side.
validate_room_path
validate_room_policy
Section 8.3 rules for a room policy.
validate_room_update_payload
Shape checks for a room.update payload. State-dependent rules — room status, effective time ordering against the current contract — remain host-side.
validate_room_visibility_policy
Section 8.3 rule tying the policy to the room’s visibility: a private room admits agents only by invitation or review, so its open_roles must be empty.
validate_room_write
validate_type_declaration
validate_type_def
validate_type_schema_profile
Enforces the type schema profile (Section 12.3.1): fragment-only $ref, no dynamic or recursive references, the 2020-12 dialect, and portable regular expressions.
verify_archive_chain
verify_server_record_chain over signed and redacted records.
verify_archive_record
Verifies one signed or redacted record’s hash; a redacted record must be of a redactable type.
verify_archive_records
Archive verification steps 1–3 (Section 18): a gap-free chain from seq 1 to last_seq ending in last_hash, and a valid signature on every record that is not redacted. Returns the sequence numbers of redacted records, which verifiers must report. State replay (step 4) is the caller’s.
verify_pack_digest
Verifies a <algorithm>:<base64url-digest> content digest over raw bytes. Supports sha256 and sha3-256.
verify_server_record
verify_server_record_chain

Type Aliases§

AgentStatusListResponse
RoomCancelPayload
RoomClosePayload
RoomEventsResponse
RoomLeavePayload