CodeSampleX

Exemplo

jsonschema-specifications 2025.9.1: jsonschema_specifications.REGISTRY

Amostra verificada para pypi jsonschema-specifications 2025.9.1: jsonschema_specifications.REGISTRY. O contrato rodou em python 3.12 · linux alpine/x64 …

sha256:9387814f67de1fce3ee02db92492bb29108149560932c5c92b6f562842049c76

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado python 3.12 linux 24 · ubuntu · glibc 2.39 x64 python 3.12 python pip 24

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-28

Caso

HOW
Objetivo
verify pkg:pypi/jsonschema-specifications@2025.9.1
Pacotes
Símbolos
  • jsonschema_specifications.REGISTRY
Ambiente
python 3.12
Criado
2026-08-28T03:52:48Z

Contrato

  1. assert REGISTRY is an instance of referencing.Registry populated with official meta-schemas
  2. assert REGISTRY contains standard draft schemas for draft-03, draft-04, draft-06, draft-07, 2019-09, and 2020-12
  3. assert REGISTRY contains Draft 2020-12 sub-vocabularies including core, applicator, and validation
  4. assert REGISTRY.contents retrieves parsed meta-schema dictionary by schema URI
  5. assert REGISTRY indexing returns Resource objects containing the parsed schema document
  6. assert REGISTRY.resolver creates a Resolver capable of resolving meta-schema resources
  7. assert REGISTRY.contents raises NoSuchResource when querying an unregistered URI
  8. assert REGISTRY can be extended with custom schema Resources via with_resource and @ operator while preserving base schemas

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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/jsonschema-specifications@2025.9.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:pypi/jsonschema-specifications@2025.9.1
Demonstrate these symbols/APIs:
  - jsonschema_specifications.REGISTRY

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:d323184723fce7cd8939c2979bbb02f86229c6ff14c15eaf8bd3b2fdaed4bc02","contract":["assert REGISTRY is an instance of referencing.Registry populated with official meta-schemas","assert REGISTRY contains standard draft schemas for draft-03, draft-04, draft-06, draft-07, 2019-09, and 2020-12","assert REGISTRY contains Draft 2020-12 sub-vocabularies including core, applicator, and validation","assert REGISTRY.contents retrieves parsed meta-schema dictionary by schema URI","assert REGISTRY indexing returns Resource objects containing the parsed schema document","assert REGISTRY.resolver creates a Resolver capable of resolving meta-schema resources","assert REGISTRY.contents raises NoSuchResource when querying an unregistered URI","assert REGISTRY can be extended with custom schema Resources via with_resource and @ operator while preserving base schemas"],"goal":"verify pkg:pypi/jsonschema-specifications@2025.9.1","kind":"HOW","packages":["pkg:pypi/jsonschema-specifications@2025.9.1"],"schemaVersion":1,"symbols":["jsonschema_specifications.REGISTRY"]},"contractCommand":["python3","test/contract.py"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"pypi","executionContext":"python","language":"python","libc":"glibc","libcVersion":"2.39","moduleSystem":"standard","os":"linux","osVersionBucket":"24","packageManager":"pip","packageManagerVersion":"24.0","runtime":"python","runtimeVersion":"3.12","schemaVersion":1},"license":"MIT-0","packages":["pkg:pypi/jsonschema-specifications@2025.9.1"],"schemaVersion":1,"subject":"pkg:pypi/jsonschema-specifications@2025.9.1","symbols":["jsonschema_specifications.REGISTRY"],"verifierAdapter":"python@1"}
pyproject.toml
[project]
name = "verify-jsonschema-specifications"
version = "0.1.0"
dependencies = [
    "jsonschema-specifications==2025.9.1",
    "referencing==0.37.0",
    "rpds-py==2026.6.3",
    "attrs==25.4.0",
    "typing-extensions==4.16.0",
]
requirements.txt
jsonschema-specifications==2025.9.1
referencing==0.37.0
rpds-py==2026.6.3
attrs==25.4.0
typing-extensions==4.16.0
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:pypi/jsonschema-specifications@2025.9.1",
  "kind": "HOW",
  "packages": [
    "pkg:pypi/jsonschema-specifications@2025.9.1"
  ],
  "symbols": [
    "jsonschema_specifications.REGISTRY"
  ]
}
test/contract.py
import jsonschema_specifications
from jsonschema_specifications import REGISTRY
from referencing import Registry, Resource
from referencing.exceptions import NoSuchResource
from referencing.jsonschema import DRAFT202012, DRAFT7


def test_registry_instance():
    assert isinstance(REGISTRY, Registry)
    assert len(REGISTRY) > 0


def test_draft_meta_schemas_present():
    expected_drafts = [
        "http://json-schema.org/draft-03/schema",
        "http://json-schema.org/draft-04/schema",
        "http://json-schema.org/draft-06/schema",
        "http://json-schema.org/draft-07/schema",
        "https://json-schema.org/draft/2019-09/schema",
        "https://json-schema.org/draft/2020-12/schema",
    ]
    for draft_uri in expected_drafts:
        assert draft_uri in REGISTRY
        contents = REGISTRY.contents(draft_uri)
        assert isinstance(contents, dict)


def test_vocabularies_present():
    vocabularies = [
        "https://json-schema.org/draft/2020-12/meta/core",
        "https://json-schema.org/draft/2020-12/meta/applicator",
        "https://json-schema.org/draft/2020-12/meta/validation",
        "https://json-schema.org/draft/2020-12/meta/meta-data",
        "https://json-schema.org/draft/2020-12/meta/format-annotation",
        "https://json-schema.org/draft/2020-12/meta/format-assertion",
        "https://json-schema.org/draft/2020-12/meta/content",
        "https://json-schema.org/draft/2020-12/meta/unevaluated",
    ]
    for vocab_uri in vocabularies:
        assert vocab_uri in REGISTRY
        res = REGISTRY[vocab_uri]
        assert isinstance(res, Resource)
        assert res.contents["$schema"] == "https://json-schema.org/draft/2020-12/schema"


def test_registry_contents_access():
    schema_2020 = REGISTRY.contents("https://json-schema.org/draft/2020-12/schema")
    assert schema_2020["title"] == "Core and Validation specifications meta-schema"
    assert schema_2020["$schema"] == "https://json-schema.org/draft/2020-12/schema"

    schema_draft7 = REGISTRY.contents("http://json-schema.org/draft-07/schema")
    assert schema_draft7["title"] == "Core schema meta-schema"


def test_registry_resource_indexing():
    resource = REGISTRY["https://json-schema.org/draft/2020-12/schema"]
    assert isinstance(resource, Resource)
    assert resource.contents["title"] == "Core and Validation specifications meta-schema"


def test_registry_resolver():
    resolver = REGISTRY.resolver()
    resolved = resolver.lookup("https://json-schema.org/draft/2020-12/schema")
    assert resolved.contents.get("title") == "Core and Validation specifications meta-schema"


def test_unregistered_uri_raises_nosuchresource():
    try:
        REGISTRY.contents("https://example.com/unregistered/schema")
        assert False, "Expected NoSuchResource"
    except NoSuchResource as exc:
        assert isinstance(exc, NoSuchResource)


def test_registry_extension():
    custom_schema = {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "$id": "https://example.com/user-schema",
        "type": "object",
        "properties": {"username": {"type": "string"}},
    }
    custom_resource = Resource.from_contents(custom_schema)
    extended = REGISTRY.with_resource("https://example.com/user-schema", custom_resource)

    assert "https://example.com/user-schema" in extended
    assert "https://json-schema.org/draft/2020-12/schema" in extended
    assert extended.contents("https://example.com/user-schema")["properties"]["username"]["type"] == "string"

    draft7_res = DRAFT7.create_resource({
        "$id": "https://example.com/item-schema",
        "type": "number",
    })
    combined = draft7_res @ REGISTRY
    assert "https://example.com/item-schema" in combined
    assert "http://json-schema.org/draft-07/schema" in combined


def main():
    test_registry_instance()
    test_draft_meta_schemas_present()
    test_vocabularies_present()
    test_registry_contents_access()
    test_registry_resource_indexing()
    test_registry_resolver()
    test_unregistered_uri_raises_nosuchresource()
    test_registry_extension()
    print("All contract assertions passed.")


if __name__ == "__main__":
    main()

Seeder de origem

anônimo