← Back to Pull requests

Session Replay models generator, part 1: read and fetch the schemas #1310

Open
unknown opened this pull request with 322 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 17, 2026 14:35 UTC
Author

What and why?

The Session Replay data models of datadog_session_replay are written by hand (lib/src/sr_data_models.dart), while dd-sdk-ios and dd-sdk-android generate theirs from rum-events-format. The Flutter models have drifted from the schema: embedded content wireframes, shape gradients, the composition tree, and the view end and visual viewport records are missing, and every schema change has to be ported by hand.

This is the first part of tools/sr_models_generator, a Dart tool that will generate those models from rum-events-format. This part covers getting and reading the schemas; nothing is generated yet, and no package code changes.

The work targets juan.naranjo/sr-schemas, which collects the parts before it is merged into develop:

1. Read and fetch the schemas (this PR)
2. Resolve the schemas into a description of the types (classes, unions, enums)
3. Print that description as Dart code
4. Command line: --check, --ref, --schemas, plus a round-trip test over the
rum-events-format samples
5. The generated models, plus a CI check that they are up to date

How?

Each commit adds one piece with its tests; reading them in order is the easiest way to review:

1. Package skeleton. tools/sr_models_generator with lints, a --help entry point and a README describing the design.
2. SchemaNode / SchemaLoader. A schema object together with its location (file and JSON pointer), and a loader that reads each file once and resolves the $ref forms rum-events-format uses: relative files (../common/x.json), fragments in another file (x.json#/definitions/y) and in the same file (#/allOf/0). Chains of references are followed, and cycles fail with the full chain in the message.
3. Configuration. sr_models_generator.yaml is the only reference this repository keeps to rum-events-format: the repository, the pinned commit, the root schema and the output file. The commit must be a full SHA, so the same pin always produces the same models. writeCommit updates the pin without touching comments.
4. Fetching the schemas. checkoutCommit checks out the pinned commit in .dart_tool/rum-events-format, downloading only that commit and reusing it offline afterwards. fetchLatest downloads the commit a branch or tag points to, which is how the pin will be moved. The schemas are never committed.

Review checklist

  • This pull request has appropriate unit and / or integration tests

  • This pull request references a Github or JIRA issue
  • Diff: 322 lines (+241 / -81) across 4 files Reviewer: joepeeples Review duration: 46m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 322 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1310"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 41.9% (MEDIUM) · Higher = larger blast radius
    41.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%