Records arrive from a gateway process that may run a different version,
so a
record can arrive with no timestamp. Those were persisted verbatim as
the zero
time, placing the row in year one and skewing budget periods, retention
and the
sessions timeline.
Substitute the server's own time instead, and warn with the field and
interception so the substitution is visible. This is what keeps an older
gateway
correct once the gateway owns stamping, in the next PR.
## Stack
| # | PR | Change |
|---|----|--------|
| 1 | #29916 | Share the structured log format definition |
| 2 | #29917 | coderd substitutes its own time for an unset one |
| 3 | #29918 | Stamp records where they are created |
| 4 | #29919 | Fold client acquisition into `DRPCRecorder` |
| 5 | #30029 | Refuse records that cannot be recorded correctly |
| 6 | #30030 | `--ai-gateway-structured-logging-source` + gateway
emission |
| 7 | #30031 | `--ai-gateway-disable-content-recording` + record filter
|
Each PR targets the one before it. Together they are #29664, which stays
open
until the stack is merged; the tip of the stack is byte-identical to its
tree.
<details>
<summary>Why the stack is ordered this way</summary>
The final design is a chain of recorder decorators:
+---------------------+
| AsyncRecorder | all records except the interception start
+---------------------+
| LogRecorder | emit the structured record
+---------------------+
| ValidatingRecorder | refuse malformed records
+---------------------+
| caller middleware | record policy, e.g. drop content
+---------------------+
| TraceRecorder |
+---------------------+
| DRPCRecorder | acquire client, send to coderd
+---------------------+
Ordering constraints:
- The record type constants (1) are the vocabulary both emitters and the
validator use, so they come first.
- Validation (5) rejects unset timestamps, so records must already be
stamped
where they are created (3). Stamping at creation leaves
`WrappedRecorder`
doing nothing but client acquisition, which is why it is folded into
`DRPCRecorder` (4) and not before.
- coderd's server-time fallback (2) is what keeps a gateway of an older
version
from persisting zero times once the gateway owns stamping (3).
- PRs 1 to 5 change no user-visible surface. Each deployment option then
lands
with the code that reads it: the log source with gateway-side emission
(6),
content recording with the filter that drops the records (7). Pool
options are
plumbed to the serving pool in 6, where the first option that needs them
arrives, rather than as an unused hook beforehand.
</details>
---
🤖 Raised by [Coder Agents](https://coder.com) on behalf of @SasSwart.