Add canonical dedicated database usage samples - #32
Merged
Conversation
Greptile SummaryThe PR adds an immutable ClickHouse-backed canonical sample contract for dedicated database usage without changing existing event, gauge, daily-rollup, or telemetry semantics.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (3): Last reviewed commit: "(fix): Bind watermarks to exact sample e..." | Re-trigger Greptile |
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
This is dependency support for Track B Phase 1 only. It does not enable any Cloud reader, billing mutation, release, or producer deployment.
Canonical contract
A sample carries environment, region, project internal ID, database internal ID, member, generation, sequence, metric, interval start/end, value, and event version. Identity and payload digests use documented length-prefixed SHA-256 encoding so producers and consumers can reproduce them across languages.
Each logical row receives an adapter-owned random ingestion ID before transport.
getSampleWatermark()performs one bounded ClickHouse snapshot query for an exact stream/range and captures exact (ingest ID, canonical ID, payload hash) entry fingerprints visible in that snapshot.findSamples()admits only that exact membership set. Later inserts cannot cross the boundary, while a repeated HTTP request retains its IDs and cannot change the canonical result.Conflict selection uses one row-consistent tuple. Multiple full payload tuples for one canonical identity produce conflict evidence and no representative sample, so independent column aggregates can neither fabricate an observation nor throw while constructing a mixed interval. Any watermark/result truncation, conflict, gap, or discontinuity makes
isComplete()false.This contract does not make a producer HTTP request or spool durable. Downstream producers must retain the identical payload until acknowledgment and publish authoritative member/generation/sequence boundaries. Consumers must query exact interval boundaries and refuse billable mutation unless
SampleResult::isComplete()is true.Verification
Seen red before implementation:
SampleTest: 3 failures/errors becauseUtopia\\Usage\\Sampledid not existExact head
edb11155408b229b5a63092f0fc2f1fd61030657:docker compose exec -T usage vendor/bin/phpunit --configuration phpunit.xml tests: 293 tests, 1,427 assertionscomposer lint: passcomposer check: pass at PHPStan maximum levelRegression coverage includes identical logical duplicates, crash retry, post-watermark insert exclusion without sleeps, conflicting values/intervals, row-consistent conflict refusal, compact sequence gaps, interval discontinuity, result and watermark truncation, range binding, stable transport retry IDs, adversarial reused-ID conflict, async-insert acknowledgment forcing, and exact schema columns.
Compatibility
The branch merges cleanly with current PR #30 and the earlier combined tree passed lint and PHPStan. The combined existing-schema database suite exposed a separate #30 upgrade-path blocker: 41 Database adapter tests reject the newly introduced
categoryattribute because setup does not backfill existing collections. This PR has no code dependency on #30 and deliberately does not modify it.