Add archetype-validation-prober: an ingestion validation gate for Pub/Sub - #425
Add archetype-validation-prober: an ingestion validation gate for Pub/Sub#425yerbis09 wants to merge 5 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
…/Sub Reference implementation demonstrating that only what minimally fits the process should ever be enqueued. An archetype (versioned JSON Schema) validates and canonicalizes every payload at the gate before publishing: - Accepted -> canonicalized (charset + Unicode NFC) and safe to publish. - Rejected -> refused synchronously with machine-readable reason codes and never enqueued, so deterministic failures cannot bounce in the queue. ClassifyingReceiver keeps poison messages out of the retry loop: only transient failures ride redelivery; functional rejects are acked and parked in quarantine. Follows the style of ordering-keys-prober (standalone Maven module, jcommander, maven-shade). Includes JUnit tests and an offline demo entry point.
8523595 to
d5d1d0e
Compare
Why an ingestion-gate validation proberAsync messaging fails silently. A malformed payload published to a topic The existing probers validate delivery semantics — This prober closes the gate at the cheapest point: before |
Design decisionsCheapest-check-first ordering (encoding → syntax → schema). NFC canonicalization before comparison. ClassifyingReceiver separates transient from functional failure. |
Smoke tests against a real Pub/Sub topicUnit tests prove the gate's logic in isolation. They do not prove it works What they test
How to run export GOOGLE_CLOUD_PROJECT=<project>
export PUBSUB_SMOKE_TOPIC=<topic> # ephemeral, created/torn down by the test
export PUBSUB_SMOKE_SUBSCRIPTION=<sub>
mvn -Dtest=ArchetypeGateSmokeIT verify -PsmokeGated behind a What they prove Happy to add |
Python companion and the LLM-agent directionCompanion repo: yerbis09/portfolioadvanced-llm — a Python port of this gate (idiomatic, 98.92% line coverage, ruff + SonarQube clean, CI/CD with secrets scanning). Why Python is the more natural host for this pattern.
The bigger picture. This positions Pub/Sub not just as transport for LLM agents but as the layer where message validity is enforced — a concrete, testable piece of GCP's agent-infrastructure story. |
- ArchetypeGateSmokeIT: integration tests against real or emulated Pub/Sub - valid payload: gate accepts, publishes, pulls back, byte-verifies round-trip - invalid payload: gate rejects, topic remains empty (never reaches publish) - encoding error: rejected at encoding stage with ENCODING_UNDECODABLE code - Archetype.fromResource(path): classpath convenience factory - pom.xml: smoke Maven profile (mvn verify -Psmoke), OFF by default - emulator mode: PUBSUB_EMULATOR_HOST=localhost:8085 - real GCP mode: GOOGLE_CLOUD_PROJECT + ADC
|
Progress update:
Next step: once the portfolio page is live, I can add the final public URL and a short showcase section. |
|
Progress update:
This keeps the Google PR self-contained and reviewable without depending on the portfolio site. |
|
I added a companion summary to the PR branch that captures the larger Python/GCP direction behind this gate work:
This is meant to show how the Java prober idea can evolve into a more operationally complete workflow while keeping the upstream PR self-contained. |
|
@yerbis09 i think you are tagging wrong person |
Summary
Adds
archetype-validation-prober, a standalone reference module that demonstrates an archetype validation gate in front of Cloud Pub/Sub.The core principle: only what minimally fits the process should ever be enqueued. A single, versioned archetype (JSON Schema) validates and canonicalizes every payload at the gate before it is published:
What's included
Archetype— the gate: canonicalize → syntactic → structural validation, cheapest check first.ValidationResult— accept (with canonical payload) / reject (with reason codes).ClassifyingReceiver— three-way delivery decision (accepted / transient / functional reject).ArchetypeValidationGateway— runnable entry point with a self-contained offline demo.archetype.schema.json— the canonical contract used by the demo.Design rationale
ack()nack()→ backoff → dead-letterPython companion implementation
A Python port of this module is maintained at yerbis09/portfolioadvanced-llm as part of a broader GCP-native LLM project.
The Python implementation demonstrates why this validation pattern is even more natural in Python:
Lock@functools.cache— 1 line, thread-safedataclass(frozen=True)+ kwargsValidationError(path, code, message)Protocol— structural typingunicodedata.normalizein stdlibThe Python port passes a review against the same design principles by Guido van Rossum, Raymond Hettinger, and Brett Cannon's documented Python idioms, and achieves 98.92% test coverage with ruff + SonarQube clean.
Build & test
Notes
This is offered as a reference/demonstration module (provided as-is, no SLA), matching the intent of the existing probers in this repo. Feedback on scope and fit is very welcome — happy to adjust or relocate it if a different home is preferred.