Repository navigation
feat(init): add the evidence-log module with a recorded payload policy - #243
Conversation
`evidence-log` is a fifth application module: a bounded in-memory ring of HTTP request and WebSocket message events, a retained/dropped counter pair, and a read-only `GET /api/events` that reports the schema, the counters, and the policy that produced the payloads. Nothing is persisted and nothing is sent off-machine; the endpoint reads a snapshot under the mutex. Text message payloads are summarized by default — length and an FNV-1a hash — and `--event-payloads verbatim` keeps the text instead. The policy is compiled into the source, written to `uvp.json` whenever the module is selected, and reported by the endpoint. Asking for it without `evidence-log` is refused before any file is written rather than accepted as an option that changes nothing. The module is opt-in everywhere, including `websocket-test`, so the default output of every existing template stays byte-identical. Assisted-by: Claude Code (Antruly-dev-1)
Review —
|
The review found #232's bounded-retention criterion unexercised: the tests read the retention constant back but never sent more events than the ring holds, so eviction and the dropped counter could both be wrong and stay green. The real-toolchain row now sends 101 requests after the WebSocket probe and asserts retained == 100, dropped >= 1, the event list length, and that the previously observed message event has left the window. Also settles three review notes: the schema now states that the log begins at process start (earlier events are unobserved, not dropped), splits ok and type by event kind, and the module docs say message events come from the websocket-echo route rather than a template's own WebSocket route. Assisted-by: Claude Code (Antruly-dev-1)
|
Addressed at Blocking 1 — bounded retention and truncation. The real-toolchain row now
That last point is the eviction check: the message event was in the window Non-blocking 1 — docs promise. Narrowed rather than hooking a template route, Non-blocking 2 — Non-blocking 3 — unobserved window. The schema now carries Validation at 🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1 |
Re-review —
|
|
Owner approval. Approved at Reviewed at At this head I verified independently: Merging as a merge commit at the exact reviewed head. Recorded by the owner's review assistant at the owner's explicit instruction. |
Fixes #232.
Adds
evidence-logas a fifth application module and the payload policy theissue asks to be visible in the manifest and the endpoint.
What the module is
kMaxEvidenceEvents = 100) of two event kinds:http(recorded from a middleware'son_sent, sostatus,duration_ms,bytes, andokare the final response's) andmessage(text and binaryframes received by the WebSocket echo route).
retainedanddroppedcounters. Truncation is counted, not silent.GET /api/events, which takes one snapshot under the mutex andreturns
schema(version, retention, the window's start, per-field meaning),payload_policy,retained,dropped, and the events. The schema says thelog begins at process start, so events before it are unobserved rather than
dropped, and
ok/typeare described per event kind. The endpoint writes nostate and persists nothing; the service makes no outbound request.
window is reported through
droppedrather than inferred fromretained.The snapshot is taken when the handler starts, so the
/api/eventsresponsedoes not contain the event for its own request; the next call does. That is
stated in the generated source and exercised by the real-toolchain row.
Payload policy (the question on the issue)
The issue says text payloads are summarized unless a caller explicitly opts
into verbatim retention, with the policy visible in the manifest and the
endpoint. With no answer to the two-shape question in the issue, this implements
shape (1), which is what the claim comment said it would do by default:
uvp init --event-payloads summary|verbatim/event_payloadsonuvp_workspace_create.summary(default): text is kept aslen=… fnv1a64=<16 hex>; binary keeps a32-byte hex prefix and length.
verbatim: the text itself is kept and JSON-escaped at read time. Binary isstill summarized, because the policy governs text.
(
kEvidencePayloadPolicy), written touvp.jsonas"evidence": {"payloads": "…"}whenever the module is selected, and returnedby the endpoint as
payload_policy.--event-payloadswithoutevidence-logis refused withinvalid_requestbefore any write: it would describe a log the workspace does not have.
evidencefield inuvp.jsonmakes the manifestunreadablerather than answering a default the file did not declare.
evidence-logis opt-in everywhere, includingwebsocket-test; the template'sdefault set stays the previous four, so every existing template's generated
files and manifest remain byte-identical. This is the reason
defaultModulesspells the four out instead of using
UVP_MODULES.Validation
Run on the rebased commit
78d183awith libuvcpp 1.7.0 at/home/zwy/下载/libuvcpp-1.7.0-linux-x64:npm run check:pr(withLIBUVCPP_ROOT,PKG_CONFIG_PATH,LD_LIBRARY_PATH):exit 0; 76 files / 1336 tests passed, 14 skipped.
npm run test:toolchain(same env), real CMake + real libuvcpp: 12/12 passed,including the new
evidence: request and message events are reported on :8098row, which builds a
hello-http+websocket-echo+evidence-logworkspace,gets a 200 on
/hello, completes a WebSocket text frame, and then checks thereported schema, policy, HTTP event, message event, and that the probe's text
does not appear in the report. It then sends one more event than the ring holds
(101 requests over
fetch, not 101 CLI spawns) and reads the endpoint back:retained == 100,dropped >= 1, the event list has 100 entries, and themessage event observed before the flood is gone — eviction and truncation are
observed, not inferred from the retention constant.
summaryworkspace served/helloand reported one HTTP event (not its own), and averbatimworkspacebuilt and served
"payload":"retained-text"withpayload_policy: "verbatim".check:fastandformat:checkclean.Skips in the gate, each with its own reason in the output: three Windows/MSVC
lanes (
not a Windows host), the native probe (uvcpp-probenot built; needsUVCPP_ENABLE_CAPI=ON), and the published-package lane (opt-in).Limits
verbatimworkspaceretains up to 100 message texts of whatever size the peer sent; that is the
policy the caller chose and the endpoint reports it.
/api/eventsis the issue's follow-up, not here.summarypolicy;verbatimis coveredby generated-source tests and the live generation check above.
Author readiness
Human owner: @Antruly
🤖 Antruly-dev-1 · AI Engineer 1 · agent:dev-ai-1