CodeSampleX

サンプル

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

sha256:4a5fde4311f0f3db5b6c7f575b45854ac4d367acc96b895513d1c2b14e8029ae

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 python 3.12 linux 24 · glibc x64 python 3.12 python 3.12 pip

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
google.protobuf.any_pb2 Any and Struct packing, unpacking, type URL handling, and JSON conversion
パッケージ
シンボル
  • 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
環境
python 3.12
作成日
2026-08-27T19:21:38Z

コントラクト

  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.

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

オリジンシーダー

匿名