CodeSampleX

Sample

google.protobuf.any_pb2 Any and Struct packing, unpacking, type URL handling, and JSON conversion

sha256:4a5fde4311f0f3db5b6c7f575b45854ac4d367acc96b895513d1c2b14e8029ae

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment python 3.12 linux 24 · glibc x64 python 3.12 python 3.12 pip

Verification-run environments

Environment Contract Stages Run
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-27

Case

HOW
Goal
google.protobuf.any_pb2 Any and Struct packing, unpacking, type URL handling, and JSON conversion
Packages
Symbols
  • google.protobuf.any_pb2.Any
  • google.protobuf.any_pb2.Any.Pack
  • google.protobuf.any_pb2.Any.Unpack
  • google.protobuf.any_pb2.Any.Is
  • google.protobuf.any_pb2.Any.TypeName
  • google.protobuf.struct_pb2.Struct
  • google.protobuf.struct_pb2.Value
  • google.protobuf.struct_pb2.ListValue
  • google.protobuf.json_format.MessageToDict
  • google.protobuf.json_format.ParseDict
Environment
python 3.12
Created
2026-08-27T19:21:38Z

Contract

  1. Struct.update populates scalar, boolean, null, nested dict, and list fields with automatic Value and ListValue wrapping, while assigning unsupported types raises ValueError.
  2. Struct helper methods get_or_create_struct and get_or_create_list instantiate child containers in-place and support append, extend, and index mutation.
  3. Any.Pack serializes arbitrary protobuf messages including Struct with default type.googleapis.com URL prefix or explicit custom prefix, and TypeName extracts the clean message name.
  4. Any.Is verifies descriptor matching, while Any.Unpack deserializes the payload into matching message instances and safely returns False without modifying destination on type mismatch.
  5. MessageToDict and ParseDict round-trip Struct directly as native dictionaries and Any containers with @type discriminator metadata.

Files

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.lock
  • requirements.txt
  • spec.json
  • test/contract.py

Download the source artifact (tar.gz)

Origin Seeder

anonymous