| 1 | --- |
| 2 | type: decision |
| 3 | id: dcr-62ecc36 |
| 4 | status: decided |
| 5 | title: "Events, metrics, and logs have different retention rules" |
| 6 | created: 2026-08-05 |
| 7 | source: design conversation, 2026-08-05 |
| 8 | --- |
| 9 | |
| 10 | # Events, metrics, and logs have different retention rules |
| 11 | |
| 12 | Domain events must be durable and replayable. Metrics may lose samples. Logs must be retained |
| 13 | according to declared policy. These three kinds of signal use the valley's infrastructure, with |
| 14 | different guarantees about what may be lost. |
| 15 | |
| 16 | ## Domain events |
| 17 | |
| 18 | Domain 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 |
| 20 | replayed deterministically. The bus is a projection of that history, as described in the |
| 21 | [architecture](../../design/architecture.md#events-and-reconciliation). |
| 22 | |
| 23 | Durability, schema validation, and replay are requirements for this class. |
| 24 | |
| 25 | ## Metrics |
| 26 | |
| 27 | Metrics include rates, latency, error counts, and resource use. The decided trial sends them on |
| 28 | ordinary NATS subjects without persistence. Losing a sample is acceptable. Metrics must not consume |
| 29 | the durable event stream's bounded storage. |
| 30 | |
| 31 | Revisit the transport if metrics enter durable streams accidentally, the subject conventions become |
| 32 | difficult to maintain, or the transport performs poorly. The distinction between durable events and |
| 33 | lossy metrics remains useful regardless of transport. |
| 34 | |
| 35 | ## Logs |
| 36 | |
| 37 | Policy must declare which logs are retained, their fidelity, and their retention period. Different |
| 38 | kinds of log can have different defaults. Small records with continuing value may be kept |
| 39 | indefinitely; large records may need shorter retention. |
| 40 | |
| 41 | This requires retention machinery as well as a policy. Existing journal rotation settings and |
| 42 | indefinitely stored run trajectories do not by themselves provide a common declared policy. |
| 43 | |
| 44 | The default policy should evolve from observed use of the data. Changes to that policy are governed |
| 45 | configuration 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 | |
| 49 | The existing `#Backup.retention` declaration in [schema/valley.cue](../../schema/valley.cue) |
| 50 | provides a model for expressing retention rules and defaults. The warehouse, query interface, and |
| 51 | log 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 |
| 53 | need not select one storage or deployment backend. |
| 54 | |
| 55 | ## Keeping useful findings |
| 56 | |
| 57 | Raw signals can expire while findings derived from them remain available. A detector can record a |
| 58 | useful finding as a durable event. A finding that should inform future work can become a |
| 59 | knowledge-graph node. |
| 60 | |
| 61 | This is how the system retains operational knowledge without retaining every sample forever. The |
| 62 | shared history required by [S4](../../design/user-scenarios.md#the-rest-of-the-ladder) depends on |
| 63 | durable events and recorded findings. |
| 64 | |
| 65 | ## Deployment and authorization |
| 66 | |
| 67 | The design defines the guarantees. The valley and host configuration select collectors, storage, and |
| 68 | other implementation details. |
| 69 | |
| 70 | Bus authentication must distinguish the writers of domain events from the writers of metrics. Hook |
| 71 | and integrator identities write domain subjects; machine services write metric subjects. This needs |
| 72 | to 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, |
| 85 | and [[ida-f16bd96]](../ideas/ida-f16bd96-the-system-observes-itself.md) describes using these |
| 86 | signals to improve the system itself. |