CodeSampleX

サンプル

rpds-py 2026.6.3: rpds.HashTrieMap, rpds.HashTrieSet, rpds.List

検証済みサンプル — pypi rpds-py 2026.6.3: rpds.HashTrieMap, rpds.HashTrieSet, rpds.List. python 3.12 · linux alpine/x64 · docker で contract を実行し、成功しました.

sha256:788a00dee2658c1c38e9231aba036b0323dfefe145ae9fe480e3fc1e4749baeb

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

実行証拠

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

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

検証実行環境

環境 コントラクト ステージ 実行日
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
ゴール
verify pkg:pypi/rpds-py@2026.6.3
パッケージ
シンボル
  • rpds.HashTrieMap
  • rpds.HashTrieSet
  • rpds.List
  • rpds.Queue
環境
python 3.12
作成日
2026-08-27T18:41:03Z

コントラクト

  1. assert HashTrieMap creates persistent mappings and supports insert, remove, discard, get, update, and convert
  2. assert HashTrieMap raises KeyError when accessing or removing missing keys
  3. assert HashTrieSet creates persistent sets and supports insert, remove, discard, union, intersection, difference, and symmetric_difference
  4. assert HashTrieSet raises KeyError when removing missing elements
  5. assert List creates persistent linked lists and supports push_front, drop_first, first, and rest
  6. assert List raises IndexError when accessing first or calling drop_first on an empty list
  7. assert Queue creates persistent FIFO queues and supports enqueue, dequeue, peek, and is_empty
  8. assert Queue raises IndexError when calling peek or dequeue on an empty queue

ファイル

  • PROMPT.md
  • csx.json
  • pyproject.toml
  • requirements.txt
  • spec.json
  • test/contract.py

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

ソース

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify pkg:pypi/rpds-py@2026.6.3
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/rpds-py@2026.6.3
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:84beb09d56624973aeffb8dc6ad799ecbdac5ec2075a60feeddf6f62111200e6","constraints":{"executionContext":"python"},"contract":["assert HashTrieMap creates persistent mappings and supports insert, remove, discard, get, update, and convert","assert HashTrieMap raises KeyError when accessing or removing missing keys","assert HashTrieSet creates persistent sets and supports insert, remove, discard, union, intersection, difference, and symmetric_difference","assert HashTrieSet raises KeyError when removing missing elements","assert List creates persistent linked lists and supports push_front, drop_first, first, and rest","assert List raises IndexError when accessing first or calling drop_first on an empty list","assert Queue creates persistent FIFO queues and supports enqueue, dequeue, peek, and is_empty","assert Queue raises IndexError when calling peek or dequeue on an empty queue"],"goal":"verify pkg:pypi/rpds-py@2026.6.3","kind":"HOW","packages":["pkg:pypi/rpds-py@2026.6.3"],"schemaVersion":1,"symbols":["rpds.HashTrieMap","rpds.HashTrieSet","rpds.List","rpds.Queue"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/rpds-py@2026.6.3"],"schemaVersion":1,"subject":"pkg:pypi/rpds-py@2026.6.3","symbols":["rpds.HashTrieMap","rpds.HashTrieSet","rpds.List","rpds.Queue"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-rpds-py"
version = "0.1.0"
dependencies = [
    "rpds-py==2026.6.3",
]
requirements.txt
rpds-py==2026.6.3
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/rpds-py@2026.6.3",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/rpds-py@2026.6.3"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.py
import rpds
from rpds import HashTrieMap, HashTrieSet, List, Queue


def test_hash_trie_map():
    base = HashTrieMap({"k1": "v1", "k2": "v2"})
    assert base["k1"] == "v1"
    assert base.get("k2") == "v2"
    assert base.get("k3", "default") == "default"
    assert len(base) == 2

    # Immutability / persistence upon insert
    added = base.insert("k3", "v3")
    assert len(added) == 3
    assert added["k3"] == "v3"
    assert len(base) == 2
    assert "k3" not in base

    # Immutability / persistence upon remove and discard
    removed = added.remove("k1")
    assert len(removed) == 2
    assert "k1" not in removed
    assert "k1" in added

    discarded = base.discard("nonexistent_key")
    assert discarded == base

    # Update and convert
    converted = HashTrieMap.convert({"x": 10, "y": 20})
    assert converted["x"] == 10 and converted["y"] == 20

    updated = base.update({"k2": "v2_updated", "k4": "v4"})
    assert updated["k2"] == "v2_updated"
    assert updated["k4"] == "v4"
    assert base["k2"] == "v2"

    # Missing key KeyError
    try:
        _ = base["missing"]
        assert False, "Accessing missing key should raise KeyError"
    except KeyError:
        pass

    try:
        base.remove("missing")
        assert False, "Removing missing key should raise KeyError"
    except KeyError:
        pass


def test_hash_trie_set():
    base = HashTrieSet(["alpha", "beta"])
    assert "alpha" in base
    assert "beta" in base
    assert "gamma" not in base
    assert len(base) == 2

    # Immutability / persistence upon insert
    added = base.insert("gamma")
    assert len(added) == 3
    assert "gamma" in added
    assert len(base) == 2
    assert "gamma" not in base

    # Immutability / persistence upon remove and discard
    removed = added.remove("alpha")
    assert len(removed) == 2
    assert "alpha" not in removed
    assert "alpha" in added

    discarded = base.discard("nonexistent")
    assert discarded == base

    # Set operations
    other = HashTrieSet(["beta", "delta"])
    union_set = base.union(other)
    assert len(union_set) == 3
    assert "alpha" in union_set and "beta" in union_set and "delta" in union_set

    inter_set = base.intersection(other)
    assert len(inter_set) == 1
    assert "beta" in inter_set

    diff_set = base.difference(other)
    assert len(diff_set) == 1
    assert "alpha" in diff_set

    sym_diff = base.symmetric_difference(other)
    assert len(sym_diff) == 2
    assert "alpha" in sym_diff and "delta" in sym_diff

    # Missing element KeyError
    try:
        base.remove("missing")
        assert False, "Removing missing element should raise KeyError"
    except KeyError:
        pass


def test_persistent_list():
    base = List([1, 2, 3])
    assert base.first == 1
    assert base.rest == List([2, 3])
    assert len(base) == 3

    # Immutability / persistence upon push_front
    pushed = base.push_front(0)
    assert pushed.first == 0
    assert len(pushed) == 4
    assert len(base) == 3
    assert base.first == 1

    # drop_first
    dropped = base.drop_first()
    assert dropped == List([2, 3])
    assert len(dropped) == 2
    assert len(base) == 3

    # Empty list raises IndexError
    empty = List()
    assert len(empty) == 0
    try:
        _ = empty.first
        assert False, "Accessing first of empty List should raise IndexError"
    except IndexError:
        pass

    try:
        empty.drop_first()
        assert False, "Calling drop_first on empty List should raise IndexError"
    except IndexError:
        pass


def test_persistent_queue():
    empty_q = Queue()
    assert empty_q.is_empty()
    assert len(empty_q) == 0

    # Immutability / persistence upon enqueue
    q1 = empty_q.enqueue("item1")
    assert not q1.is_empty()
    assert len(q1) == 1
    assert empty_q.is_empty()

    q2 = q1.enqueue("item2")
    assert q2.peek() == "item1"
    assert len(q2) == 2

    # Dequeue
    q3 = q2.dequeue()
    assert q3.peek() == "item2"
    assert len(q3) == 1
    assert len(q2) == 2
    assert q2.peek() == "item1"

    # Empty queue raises IndexError
    try:
        empty_q.peek()
        assert False, "Calling peek on empty Queue should raise IndexError"
    except IndexError:
        pass

    try:
        empty_q.dequeue()
        assert False, "Calling dequeue on empty Queue should raise IndexError"
    except IndexError:
        pass


def main():
    test_hash_trie_map()
    test_hash_trie_set()
    test_persistent_list()
    test_persistent_queue()
    print("All contract assertions passed.")


if __name__ == "__main__":
    main()

オリジンシーダー

匿名