mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 05:44:38 +08:00
1.6 KiB
1.6 KiB
Message Log
This document defines the persisted chat-history format used by TNT 1.x.
Format: messages.log v1
Each record is one UTF-8 line:
RFC3339_UTC|username|content\n
Example:
2026-05-27T12:34:56Z|alice|hello
Rules:
- Timestamp is strict UTC RFC3339:
YYYY-MM-DDTHH:MM:SSZ. - The separator is literal
|. - A valid record has exactly three fields and exactly two separators.
usernameandcontentmust be non-empty valid UTF-8.usernamemust fitMAX_USERNAME_LEN;contentmust fitMAX_MESSAGE_LEN.- Every complete record ends with
\n.
The file has no header. The version is defined by this record contract so existing append-only logs remain readable.
Write Behavior
message_save() sanitizes fields before appending:
|,\n, and\rin usernames become_.|,\n, and\rin content become spaces.- Timestamps are written in UTC.
Private messages are not written to messages.log.
Replay And Search
Replay and search use the same strict parser. TNT skips records that are:
- malformed or missing fields
- invalid UTF-8
- too long
- outside the accepted timestamp window
- terminated without a trailing newline
- written with extra separators
Skipping a bad record is intentional recovery behavior. A truncated final line is treated as a partial append and ignored rather than replayed.
Compatibility
The v1 record format is stable for TNT 1.x. Future incompatible storage changes must document downgrade behavior in release notes and provide an operator-visible migration or export path.