gunk-dev/the-valley

dcr-62ecc36-signal-contracts.md

source8c40ee5f164cmain's published tip history
4.2 KiB · Rendered
1---
2type: decision
3id: dcr-62ecc36
4status: decided
5title: "Events, metrics, and logs have different retention rules"
6created: 2026-08-05
7source: design conversation, 2026-08-05
8---
9
10# Events, metrics, and logs have different retention rules
11
12Domain events must be durable and replayable. Metrics may lose samples. Logs must be retained
13according to declared policy. These three kinds of signal use the valley's infrastructure, with
14different guarantees about what may be lost.
15
16## Domain events
17
18Domain events use the durable JetStream stream and the contracts in
19[schema/events.cue](../../schema/events.cue). Repository events can be reconstructed from Git and
20replayed deterministically. The bus is a projection of that history, as described in the
21[architecture](../../design/architecture.md#events-and-reconciliation).
22
23Durability, schema validation, and replay are requirements for this class.
24
25## Metrics
26
27Metrics include rates, latency, error counts, and resource use. The decided trial sends them on
28ordinary NATS subjects without persistence. Losing a sample is acceptable. Metrics must not consume
29the durable event stream's bounded storage.
30
31Revisit the transport if metrics enter durable streams accidentally, the subject conventions become
32difficult to maintain, or the transport performs poorly. The distinction between durable events and
33lossy metrics remains useful regardless of transport.
34
35## Logs
36
37Policy must declare which logs are retained, their fidelity, and their retention period. Different
38kinds of log can have different defaults. Small records with continuing value may be kept
39indefinitely; large records may need shorter retention.
40
41This requires retention machinery as well as a policy. Existing journal rotation settings and
42indefinitely stored run trajectories do not by themselves provide a common declared policy.
43
44The default policy should evolve from observed use of the data. Changes to that policy are governed
45configuration changes, including when the system proposes them through the observation loop in
46[[ida-a006b02]](../ideas/ida-a006b02-ooda-over-neural-nodes.md).
47[self-transparency.md](../../design/self-transparency.md) describes the purpose of that loop.
48
49The existing `#Backup.retention` declaration in [schema/valley.cue](../../schema/valley.cue)
50provides a model for expressing retention rules and defaults. The warehouse, query interface, and
51log transport remain open. [[ida-48c8868]](../ideas/ida-48c8868-stores-beyond-git.md) and
52[[ida-b9f646c]](../ideas/ida-b9f646c-nix-backend-not-substrate.md) explain why these requirements
53need not select one storage or deployment backend.
54
55## Keeping useful findings
56
57Raw signals can expire while findings derived from them remain available. A detector can record a
58useful finding as a durable event. A finding that should inform future work can become a
59knowledge-graph node.
60
61This is how the system retains operational knowledge without retaining every sample forever. The
62shared history required by [S4](../../design/user-scenarios.md#the-rest-of-the-ladder) depends on
63durable events and recorded findings.
64
65## Deployment and authorization
66
67The design defines the guarantees. The valley and host configuration select collectors, storage, and
68other implementation details.
69
70Bus authentication must distinguish the writers of domain events from the writers of metrics. Hook
71and integrator identities write domain subjects; machine services write metric subjects. This needs
72to be considered when resolving [[bd-d853d9c]](../bugs/bd-d853d9c-bus-unauthenticated.md).
73
74## Open questions
75
76- What default retention periods and fidelity levels suit each kind of log?
77- What evidence should drive changes to retention policy?
78- Which retained signals need offsite backup?
79- Which warehouse and query interface should be used?
80- Should logs pass through NATS or use another transport, such as a journal collector?
81- What metric volume can the trial transport sustain on the pilot host?
82
83[[ida-b48bded]](../ideas/ida-b48bded-production-dags-and-events.md) describes the event model.
84[[ida-b42d112]](../ideas/ida-b42d112-harness-log-is-normalized.md) covers normalized agent-run logs,
85and [[ida-f16bd96]](../ideas/ida-f16bd96-the-system-observes-itself.md) describes using these
86signals to improve the system itself.