Skip to content

test(diagnostics): add InMemory/Sqlite StructuredLog store conformance - #8151

Merged
sfmskywalker merged 3 commits into
mainfrom
cursor/structured-logs-conformance-b0d0
Sep 14, 2026
Merged

sfmskywalker merged 3 commits into
mainfrom
cursor/structured-logs-conformance-b0d0

Conversation

@sfmskywalker

@sfmskywalker sfmskywalker commented Sep 14, 2026

Copy link
Copy Markdown
Member

Fixes #8118

Purpose

Add a shared InMemory / Relational (Sqlite) conformance matrix for IStructuredLogStore so Take clamp, SourceId tie-break, ListSources heartbeat, DroppedEvents, and portable filters cannot drift independently again.

Scope

  • Bug fix (behavior change)
  • Refactor (no behavior change)
  • Documentation update
  • Formatting / code cleanup
  • Dependency / build update
  • New feature

Description

Problem

Diagnostics StructuredLogs ship parallel InMemory and Relational IStructuredLogStore implementations. Filter/order/Take/ListSources/DroppedEvents invariants lived in separate unit vs Sqlite suites, so one path could regress without the other failing. Companion PRs already aligned production behavior (#8147 Take clamp, #8148 SourceId sort + ListSources registry/heartbeat).

Solution

New Elsa.Diagnostics.StructuredLogs.Persistence.ConformanceTests project follows the recent Labels/Alterations/Secrets pattern: shared scenarios + InMemory and Sqlite fixtures.

Locked shared contracts:

  • Null Take and oversize Take use StructuredLogsOptions.MaxRecentLogQuerySize; negative ceiling or Take returns empty
  • Timestamp ties order by SourceId, then Sequence, then Id (each stage asserted with preceding fields tied; Sequence IDs sort opposite Sequence so Id-only order cannot pass)
  • ListSources prefers in-process registry metadata and marks sources Stale after SourceHeartbeatTimeout
  • Portable exact-case equality, category prefix, text, level, and time-range filters apply before Take

Documented store-specific contracts (not chased into a false shared equality):

  • QueryAsync.DroppedEvents is the InMemory ring overflow count; Relational QueryAsync stays 0 (write-queue drops live on storage diagnostics)
  • Case-differing equality filters are collation-dependent on SQL (= / Sqlite BINARY) vs InMemory OrdinalIgnoreCase — tests seed exact-case values

No production store changes: #8147/#8148 already aligned the shared contracts; conformance did not expose remaining drift that needed a prod fix.

Verification

Steps:

  1. dotnet test test/integration/Elsa.Diagnostics.StructuredLogs.Persistence.ConformanceTests/Elsa.Diagnostics.StructuredLogs.Persistence.ConformanceTests.csproj
  2. Confirm InMemory and Sqlite suites both run the shared scenarios.

Expected outcome: the new matrix is green on both providers; Take / SourceId / Sequence / Id / ListSources / DroppedEvents / portable filters stay locked.

Local results:

  • Elsa.Diagnostics.StructuredLogs.Persistence.ConformanceTests (net10.0): 22 passed (11 shared scenarios × InMemory + Sqlite)

Tip: 124d27e3e on cursor/structured-logs-conformance-b0d0

Checklist

  • The PR is focused on a single concern
  • Commit messages follow the recommended convention
  • Tests added or updated (if applicable)
  • Documentation updated (if applicable)
  • No unrelated cleanup included
  • All tests pass
Open in Web Open in Cursor 

Add a shared IStructuredLogStore matrix that locks Take clamp, SourceId
tie-break order, ListSources registry/heartbeat, DroppedEvents vs storage
diagnostics, and portable exact-case filters after #8147/#8148.

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
@sfmskywalker
sfmskywalker marked this pull request as ready for review September 14, 2026 07:12
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

Safe to merge.

Summary

  • This PR adds a shared conformance suite for in-memory and SQLite structured-log stores. It covers query-size clamping, deterministic ordering, portable filters, source heartbeat status, and provider-specific dropped-event behavior; the latest revision independently verifies the Sequence and ID ordering tie-breaks.

Reviews (3) · Last reviewed commit: "test(diagnostics): isolate Sequence tie-..."

Cover the later IStructuredLogStore order stages independently so a
SourceId-only assertion cannot hide Sequence or Id regressions.

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Use IDs that sort opposite Sequence so a skip-Sequence, order-by-Id
implementation cannot pass the shared matrix.

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>

@sfmskywalker sfmskywalker left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — Round 1/4 @ 124d27emain

Verdict: APPROVE + HIGH (formal event COMMENT — own-PR APPROVE blocked for sfmskywalker)

What changed (fixes #8118)

Shared InMemory / Sqlite conformance suite for IStructuredLogStore (Labels/Alterations/Secrets pattern):

  • Take: null → MaxRecentLogQuerySize, oversize clamp, negative Take / negative max → empty
  • Order: SourceId, then Sequence, then Id (each stage isolates preceding ties; Sequence/Id seeds cannot pass via the other key)
  • ListSources: registry metadata + SourceHeartbeatTimeoutStale
  • Filters: exact-case equality, category prefix, text, level, time range before Take
  • DroppedEvents: InMemory ring count vs Relational QueryAsync 0 — intentional split, locked both ways
  • README documents non-portable case/= collation and SourceId sort case (lowercase seeds)

Scenario fixture flushes Sqlite write buffer, validates DI scopes, cleans temp DB + pool.

Soft steers (non-blocking)

  • No dedicated ReceivedAt-only tie-break case (Timestamp tied, ReceivedAt differs) — optional follow-up; SourceId/Sequence/Id stages are solid.
  • Sqlite path sets RecentLogCapacity in the ring-overflow test but Relational ignores it for QueryAsync — intentional via ReportsRingDroppedEvents.

Merge gates

  • Code Review: APPROVE + HIGH @ 124d27e
  • Greptile: tip 5/5
  • CI: green on tip ✓

@sfmskywalker
sfmskywalker merged commit 90c29fb into main Sep 14, 2026
14 checks passed
@sfmskywalker
sfmskywalker deleted the cursor/structured-logs-conformance-b0d0 branch September 14, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add shared InMemory/Relational conformance tests for Diagnostics StructuredLog store

2 participants