Necoherence for Python
This package is the Python implementation of Necoherence, for Python 3.12 or later. It uses only the standard library at run time.
Accepting a semantic profile
The caller passes a versioned semantic profile when decoding declarations and when accepting a generated library. The accepted profile defines the wire format used by validation, encoding and decoding, and execution.
The expected profile reference, the sources, and the trusted bytes are passed as arguments separate from the input bytes.
from necoherence.signature_values import ValueContext
from necoherence.type_signatures import checkLibrary, decode_profile_artifact
def decide(expected, sources, trusted, input_bytes, library, type_id, value):
profile = decode_profile_artifact(expected, sources, trusted, input_bytes)
checked = checkLibrary({**library, "profile": profile})
context = ValueContext({
"profile": checked.value["profile"], "nodes": checked.value["nodes"],
})
return context.validate(type_id, value)
Failures are returned as the following types, one for each cause:
WireFailure: the profile's wire value is malformedDeclarationFailure: the profile or the library violates a declaration conditionAdmissionFailure: the profile differs from the expected reference or sourcesMeaningFailure: a type lacks a definition of its meaningValueFailure: validation rejected the value
Other features
Besides the features listed in the project overview, the package provides the following:
- Declaration checking: detects errors in declarations of types and operations, such as duplicate identifiers and references to undeclared types or definitions
- Runtime for generated code: the shared value validation and codec routines that generated Python code calls at run time
The optional HTTP adapter is distributed separately as necoherence-http-adapter. It executes network-effect commands and returns observations to the core ledger.
Tools
The generator, which produces Python types and codecs from declarations of types and operations, is in tools/. Its license is AGPL-3.0-only.
Examples
Examples are in examples/.
Testing and type checking
The following commands run the tests and the type checks:
python3 -m pip install ".[dev]"
python3 -m pytest -q
python3 -m mypy src tests
License
Metadata
Release files for necoherence 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| necoherence-0.2.2.tar.gz | 93.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| necoherence-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 157.9 kB
Release files / necoherence-0.2.2.tar.gz
| Download URL | necoherence-0.2.2.tar.gz |
|---|---|
| Size | 93.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3d5ae44873fb1f8c7a2bc530c05a52764bc323230958d6ba534f77c46fece1a
|
|
BLAKE2b-256 checksum How to use checksums |
efd430b76f32fb86ffc4c350cc50cb54533abd52342a4be816a532ed063e966f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Release files / necoherence-0.2.2-py3-none-any.whl
| Download URL | necoherence-0.2.2-py3-none-any.whl |
|---|---|
| Size | 64.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c110e35d14039f1118835481d520ffb3c905e34f079d0f4e4feb1f5c61777ff
|
|
BLAKE2b-256 checksum How to use checksums |
b8406884905e730eb2740a15a29cdc13716ee9162460d22ba63ab918fd12daf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.12
|
Security for necoherence 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.