observability

package
v0.1.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

transcript.go writes transcript.json into the SAME directory as the causal event log, which the Spawnfile compiler mounts unconditionally so the social record survives container teardown even for a purely in-memory room store.

THIS CHANGES THAT VOLUME'S CONTRACT, DELIBERATELY. It previously held only hashes: the causal log records content_sha256, never message text and never a sender. It now also holds message bodies. That is not an incidental widening: agent speech is the research data the memetics programme exists to study, and a run record that cannot show who said what to whom cannot support the claim that agents held a conversation.

Two properties keep this an attestation rather than a second, drifting copy of the truth:

  • Text is checkable. Each message's sha256(json.Marshal(Parts)) equals the content_sha256 the causal log already recorded for that message_id, so a reader verifies the transcript against the sealed log rather than trusting it.
  • Attribution is stated, never assumed. `from` is what the SENDER claimed and a sender can claim anything; the authenticated identity is the causal event's principal_id, which causalPrincipal() derives from auth claims alone. The attestation block therefore reports three states and not two: attested, violated, and unattested, because a network running auth.mode: none stamps system:moltnet.anonymous and there is then nothing to compare against. Unattested must never be read as passed.

Index

Constants

This section is empty.

Variables

View Source
var DefaultMetrics = NewMetrics()

Functions

func Logger

func Logger(ctx context.Context, component string, attrs ...any) *slog.Logger

func NetworkStreamID added in v0.1.14

func NetworkStreamID(networkID string) string

NetworkStreamID builds the stream_id convention moltnet uses for message.accepted causal events: "network:<networkID>".

func NewRequestID

func NewRequestID() string

func NormalizeRequestID

func NormalizeRequestID(value string) string

func RedactURL

func RedactURL(raw string) string

func RequestID

func RequestID(ctx context.Context) string

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

func WriteMessageAcceptedFixture added in v0.1.14

func WriteMessageAcceptedFixture(w io.Writer, runID string) error

WriteMessageAcceptedFixture writes exactly two message.accepted causal events for runID to w, through the real CausalWriter (so seq assignment and CausalEvent.Validate both run for real, the same as production moltnet). It is B92's cross-repo conformance fixture: the root conformance harness stitches these two events into the daimon/mneme/ simfile chain (see specs/causal-event.v1.schema.json and src/ledger/conformance.ts).

Types

type CausalWriter added in v0.1.14

type CausalWriter struct {
	// contains filtered or unexported fields
}

CausalWriter is an append-only per-network causal JSONL sink. It owns sequence assignment for every (run_id, stream_id) it sees, so callers never have to coordinate contiguity themselves: Append fills in event.Emitter.Seq before validating and writing the record.

func NewCausalFileWriter added in v0.1.14

func NewCausalFileWriter(path string) (*CausalWriter, error)

NewCausalFileWriter opens (creating parent directories and the file as needed) an append-only JSONL file at path for causal events.

func NewCausalWriter added in v0.1.14

func NewCausalWriter(writer io.Writer) *CausalWriter

NewCausalWriter wraps an arbitrary io.Writer (a file, an in-memory buffer in tests, etc.) as a CausalWriter.

func (*CausalWriter) Append added in v0.1.14

Append assigns the next contiguous seq for (event.RunID, event.Emitter.StreamID), validates the resulting record, and appends it as one JSONL line. It returns the stamped event (with Emitter.Seq populated) regardless of whether the append itself succeeded, so callers can log the attempted record on failure.

func (*CausalWriter) Close added in v0.1.14

func (w *CausalWriter) Close() error

Close releases the underlying writer if it supports io.Closer.

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics() *Metrics

func (*Metrics) AddActiveAttachments

func (m *Metrics) AddActiveAttachments(delta int64)

func (*Metrics) AddActiveSSE

func (m *Metrics) AddActiveSSE(delta int64)

func (*Metrics) RecordDroppedEvent

func (m *Metrics) RecordDroppedEvent()

func (*Metrics) RecordHTTPRequest

func (m *Metrics) RecordHTTPRequest(method string, route string, status int, duration time.Duration)

func (*Metrics) RecordRelay

func (m *Metrics) RecordRelay(result string)

func (*Metrics) RecordStoreHealth

func (m *Metrics) RecordStoreHealth(ok bool)

func (*Metrics) RenderPrometheus

func (m *Metrics) RenderPrometheus() string

func (*Metrics) ServeHTTP

func (m *Metrics) ServeHTTP(response http.ResponseWriter, _ *http.Request)

type TranscriptWriter added in v0.1.14

type TranscriptWriter struct {
	// contains filtered or unexported fields
}

TranscriptWriter writes the social record beside causal.jsonl. Bodies are research data for the memetics programme, not an incidental widening of the causal volume: this artifact makes accepted message text available for replay and lets readers attest it against the adjacent content_sha256.

func NewTranscriptFileWriter added in v0.1.14

func NewTranscriptFileWriter(path string, _ string) (*TranscriptWriter, error)

func (*TranscriptWriter) Append added in v0.1.14

func (w *TranscriptWriter) Append(message protocol.Message, principalID string) error

func (*TranscriptWriter) Close added in v0.1.14

func (w *TranscriptWriter) Close() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL