Skip to main content

Module origin_sig

Module origin_sig 

Source
Expand description

A stored record’s amx is believed only if srv signed it (docs/specs/SPEC_MESSAGE_ORIGIN_AND_ONE_CONTAINER_2026_10_25.md §6.1).

“Only srv writes amx” holds for the protocol. The record also has to hold up when it is read back from storage, where anything able to append a line could write "amx":{"origin":{"kind":"user"}}. So:

  • srv signs the record it writes (sign_line): an HMAC-SHA256 over the record’s owner, its ts_ms, the message content, and the whole amx object, with a key an agent can’t read ([key]).
  • everything srv hands to a viewer first goes through vet_line, which removes the record’s whole amx object and puts back only what the MAC covers, marked verified. A missing, wrong or copied-onto-other-content MAC leaves the record with no amx at all: untyped, so a viewer shows it in the container and never as the human.

The MAC binds the record’s owner, not the zone it sits in: the agent (agent:<id>:current, …:archive:<ms>) or, for a record with no agent, the block. Archive, restore and clear keep a line’s bytes and still verify; a copy to another owner (a fork) does not, so a fork shows its parent’s lines untyped.

Structs§

ForkCover
What a fork’s mark says about the history copied into the fork: it came from parent, an agent that ran in runtime, and the first upto bytes of the fork’s transcript are that copy.

Enums§

WriterRuntime
Which runtime wrote the lines of an agent’s output.

Constants§

SIG_LEN
The length of a signature as written: SHA-256 as hex.

Functions§

echoed_prompt
The text of the user line line of a provider’s own output, when it is the provider echoing the prompt (see [content_of]); None for anything else, a user record srv wrote included.
fork_cover
What the mark mark (fork.json) of the fork fork says about its copied history, when its signature holds; None for a mark that has none, or whose facts were changed or are another fork’s.
owner_for_block
The owner of the records block_id writes: its agent, when it has one, else the block itself. The same rule the writer uses (persist_user_line_as is given the agent zone resolve_global_output_zone finds from the block).
owner_for_read
The owner of the records read from read_zone for block_id: a global or archive zone names its agent; the block’s own copy is the block’s.
owner_of_zone
The owner a record is signed for, from the zone it is written to: the agent id of an agent:<id>:… zone, else the zone itself (a block id).
resign_line
A line signed for from_owner, to be signed for to_owner instead (a fork’s copy of its parent’s transcript): where its signature is, and the one for the new owner, both SIG_LEN bytes of hex, so the line keeps its length and everything after it keeps its offset. None for a line that does not verify for from_owner, or has no signature to swap: a record nobody signed is never signed here, so a forged line cannot be made good by a fork.
sign_fork_mark
The signature over a fork mark’s facts, for the fork fork (agent ids): which parent, which runtime, how many bytes.
sign_line
line with ts_ms and sig added to its amx, for owner. A line with no amx object (or that isn’t a JSON object) is returned as it is.
stamp_writer
line, an output line an agent’s process wrote, as srv stores it: the agent’s own bytes, with amx.writer saying which runtime wrote it, and which agent, signed for owner, added as the last member. The agent’s bytes and key order are kept (readers look for "type":"stream_event" and "subtype":"init" near the start of a line). Whatever amx the line already carries is the agent’s own words and is dropped first, never kept or merged; such a line (rare) is written again from its parsed record, so its key order and number spelling are not kept. None for a line that isn’t a JSON object, and for a streaming delta (never a message, and kept compact), which are stored as they are.
vet_line
What a viewer may be shown for stored line of owner: the line with its amx replaced by the verified parts of it (origin, notes, via, device, message_id, v, plus verified: true), or with no amx at all when it doesn’t verify. A line that can’t carry one is returned as it is. A line that may carry one but can’t be read here (a viewer’s parser takes input serde_json refuses: nesting past its limit, a lone surrogate escape) is blanked, never passed on with its amx.
vet_lines
vet_line over a list of lines, each changed in place only when it carries an amx.