feat(trace): event model with run-level format version and tolerant read path - #2872
Merged
esokullu merged 1 commit intoAug 21, 2026
Merged
Conversation
…nt read path Introduce trace/event-model.js as the single source of truth for the per-run event vocabulary (EVENT_KINDS), the run-level trace format version (TRACE_FORMAT_VERSION), and write-side envelope validation (makeEvent rejects unknown kinds and data that cannot survive a JSON round-trip). The recorder routes every event write through the model and stamps traceFormatVersion on new run records. Read side becomes tolerant instead of silently losing events: the Traces UI renders unknown kinds as an explicit placeholder (and collapses ignorable kinds), and the Markdown exporter skips them with a count in the footer. Old runs without the version field remain fully readable. Mirrored to Firefox. Closes webbrain-one#2869
|
@alectimison-maker is attempting to deploy a commit to the esokullu's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trace/event-model.js(Chrome + Firefox): authoritativeEVENT_KINDScatalog,TRACE_FORMAT_VERSION, andmakeEvent()envelope construction with write-side validation.traceFormatVersion: 1on new run records.Motivation
Closes #2869.
WebBrain's trace events were free-form
{runId, seq, ts, kind, data}with three internal problems:conversationId: nullruns,trace-export.jshas legacy branches).Design
EVENT_KINDScovers all 9 existing kinds and is consulted by the recorder, the Traces UI, and the exporter, so a new event type has one declared home instead of per-reader lists.IGNORABLE_KINDSstarts empty; the mechanism is in place so a future "safe to collapse" event type has a defined place. The UI honors the flag; nothing is ignorable today.makeEvent()returnsnull(never throws) for unknown kinds or data that cannot survive a JSON round-trip (circular, BigInt). The recorder skips a null envelope with a warning — a recording bug surfaces at write time and can never break a run. The screenshot timeline marker now goes through the same envelope path.traceFormatVersion: 1; older runs without the field (= version 0) are untouched.validateEventLog()provides read-side tooling (seq contiguity + unknown-kind detection) for tests and future consumers.Testing
node test/run.js— passed, 1959 tests (7 new: catalog coverage vs recorder usage, envelope validation, log validation, mirror identity + browser-neutrality, recorder wiring, exporter skip/count, UI placeholder)npm run test:toolbar-guard— passed (33 tests)npm run test:security— passed (60/60 checks)node --checkon every touched file — passedSkipped: unpacked-browser manual verification (no browser session available in this environment); both Chrome and Firefox builds are covered by the mirror-consistency tests instead. Untested browsers: Chrome, Firefox (runtime UI rendering of the new placeholder not manually exercised).
Compatibility and risks
traceFormatVersionremain fully readable; the version is informational today and becomes the negotiation point for future format changes.Scope
Deliberately deferred (follow-ups, separate PRs): turn/step boundary events, session lineage fields, checkpoint/repair semantics, projections, OTLP association. This PR only establishes the event model foundation with no user-visible behavior change.