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

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. 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()

오리진 시더

익명