[FEAT]: Canonical versioned trace/result serializer (WS0-05 PR 1) - #185
Draft
Nina Chikanov (nina-msft) wants to merge 1 commit into
Draft
[FEAT]: Canonical versioned trace/result serializer (WS0-05 PR 1)#185Nina Chikanov (nina-msft) wants to merge 1 commit into
Nina Chikanov (nina-msft) wants to merge 1 commit into
Conversation
Introduce rampart/core/serialization.py as the single, neutral full-fidelity Result <-> dict round-trip (Decision D6 gate). Every record carries a single root version (rampart.trace.v1) and decoding dispatches on it, failing closed on an unknown major. The canonical layer defines the supported value domain only: enums encode to .value and fail closed on unknown values, harm_category is a passthrough string, floats must be finite, and free-form maps must be JSON-safe. Transport hygiene (ANSI stripping, float normalization, repr() fallback, size caps) stays at the xdist boundary and is not duplicated here. Binary payloads fail closed pending the WS7 artifact resolver rather than being coerced to text. Also lands the written migration policy (docs/concepts/trace-schema.md): additive-optional = no bump, structural = major bump, missing = not recorded, readers fail closed on unknown major, with named reserved additive slots so WS8 provenance needs no hard migration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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.
WS0-05 — PR 1: Canonical versioned trace/result serializer (Decision D6 gate)
First PR of the WS0-05 execution plan. Pure addition — no existing consumer is
rewired here, so nothing breaks; later PRs project reporting/xdist onto this module.
What this lands
ampart/core/serialization.py** — the single, neutral full-fidelity
Result⇄dictround-trip. Public surface isResultRecord.to_dict/from_dictplus thinserialize_result/deserialize_resultwrappers.rampart.trace.v1stamped on every record; decodingdispatches through a
_DECODERSregistry and fails closed on an unknown major.Independent of the xdist transport envelope version (
rampart.xdist.v2)..valueand failclosed on unknown;
harm_categorypassthrough string; floats must be finite;free-form maps must be JSON-safe (no
repr()/default=strfallback — thatstays in the xdist transport). Reserved xdist bookkeeping keys are stripped from
the canonical body.
resolver, rather than being coerced to
PayloadFormat.TEXT.PopulationRef.docs/concepts/trace-schema.md(design §4):additive-optional = no bump; structural = major bump; missing = not recorded;
named reserved additive slots so WS8 provenance needs no hard migration.
Tests
tests/unit/core/test_serialization.py— round-trip, field-exhaustiveness viadataclasses.fields(), version dispatch + fail-closed, additive tolerance,missing-field defaults, value-domain fail-closed, and binary-payload fail-closed.
18 pass; full core suite (398) green; ruff + ty clean.
Still to do in this PR (draft)
trace.v1.schema.jsonfrom encoder output over a fixturescorpus + a CI
git diff --exit-codedrift gate (design deliverable).Refs WS0-05 (#10594). Blocks WS6/WS7; shares the serializer with #10596 (xdist merge).