chtypes 2.0.0.dev3__tar.gz → 2.0.0.dev4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/CHANGELOG.md +9 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/PKG-INFO +3 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/README.md +2 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/pyproject.toml +1 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/__init__.py +8 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_abi2/_decls.py +2 -2
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_abi2/_errmap.py +1 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_abi2/_vocab.py +31 -5
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_decode.py +22 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_channel.py +39 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_constants.py +5 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_ensure.py +24 -4
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_errors.py +15 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_http.py +28 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_oci.py +10 -6
- chtypes-2.0.0.dev4/src/chtypes/_ocifetch/_retired.py +77 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/errors.py +12 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/registry.py +1 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/results.py +25 -4
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_public_server.py +64 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_public_setup_cases.py +28 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/cli/test_main.py +40 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_conformance.py +8 -0
- chtypes-2.0.0.dev4/tests/ocifetch/test_retired.py +181 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/uv.lock +1 -1
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/.gitignore +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/LICENSE +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/__main__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_abi2/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_abi2/_errors.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_abi2/_loader.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ed25519.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_guard.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_input.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_dsse.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_faults.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_goldens.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_layout.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_lock.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_referrers.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_ocifetch/_unpack.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/_setup.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/library.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/src/chtypes/py.typed +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/_stub_tree.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/conftest.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_conformance.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_dev_fingerprint.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_goldens_runner_stub.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_loader.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_public_library.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_public_open.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_public_registry.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/abi2/test_reader_rules.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/api/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/api/test_decode.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/api/test_input.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/api/test_vocab.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/cli/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/cli/conftest.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/cli/test_devchannel.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/conftest.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/goldens_v1/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/goldens_v1/data/stub-goldens.json +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/goldens_v1/test_runner.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/__init__.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/_bundle_support.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/_registry_support.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/_sign_support.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/conftest.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_cache_roots.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_cache_strict.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_devchannel.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_dsse.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_ensure.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_goldens.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_http.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_layout.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_lock.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_oci.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_seam_gate.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/ocifetch/test_unpack.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/test_abi_identity.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/test_cache_roots_api.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/test_devchannel_registry.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/test_ed25519.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/test_examples_tour.py +0 -0
- {chtypes-2.0.0.dev3 → chtypes-2.0.0.dev4}/tests/test_fetch_options.py +0 -0
|
@@ -8,8 +8,17 @@ The four bindings in this repository are released together and give one answer,
|
|
|
8
8
|
|
|
9
9
|
### Added
|
|
10
10
|
|
|
11
|
+
- The server's filter-declined settings (ABI v2; moves the dev fingerprint): `SchemaServer.filter_declined_settings`, a tuple of `DeclinedSetting` (`name`, `tier`), decoded from `schema_description`'s new required `server.filter_declined_settings`, with the new `DeclinedTier` vocabulary (`PREDICATE`, `PREDICATE_UNFLIPPED`, `RESULT_CONTENT`, and its unknown(n)). `compile_filter` on a schema whose server lists any is the library's `CHS_DECLINED`, an `UnsupportedError` carrying its message; a filter's own settings other than `session_timezone` are no longer declined at compile, and a declined one is named at evaluation instead.
|
|
12
|
+
- The v2 spec states that a filter verdict counts only when the evaluation's outcome is `ok`: over a body a server would not accept, every verdict is `d`.
|
|
13
|
+
- The v2 spec publishes the WHERE-affecting settings lists (`spec/abi-v2/where-settings/`) with the consumer rule.
|
|
14
|
+
- The v2 spec publishes the filter decline-reasons catalog (`spec/abi-v2/declines/`).
|
|
15
|
+
- A `410 Gone` is a retired repository, and permanent (#571). Any request the fetch layer makes (a tag, an alias, a digest, a blob, `tags/list`, the referrers API or its fallback tag, after a redirect too) that answers `410` is now the new code `CHTYPES_SOURCE_RETIRED` (exit status 10), never retried and never sent to the next base, nor from the dev channel's alias to its tag. It was `CHTYPES_SOURCE_UNREACHABLE` (exit 3) with the registry's message dropped, and Go, Python and Rust moved on to the next base, so a mirror's 404 could hide the retirement. The error names the URL that answered and carries the registry's own message, with control and bidirectional-formatting characters removed and cut to 256 code points: Go `CodeSourceRetired` (`errors.Is(err, ErrSourceRetired)`), Python and TypeScript `SourceRetiredError`, Rust `Error::SourceRetired`. The rule is `docs/guides/fetch-v1.md` section 2, "A retired repository", and the `retired-410-*` and `list-tags-retired-410` conformance cases and one shared message table (`tests/fixtures/retired-message/cases.json`) hold all four bindings to it.
|
|
11
16
|
- A 2.0.0-dev SDK prefers the newest build of its own fingerprint (#511). A version request resolves `<tag>--fp-<fingerprint>` first, the alias the staging dev registry serves beside every dev tag, with the binding's own generated ABI fingerprint, and the tag itself only when every base answers the alias 404; any other failure of the alias request is that failure, with no fallback, and an alias whose index lacks the platform is `CHTYPES_ARTIFACT_UNPUBLISHED`. The dev channel's cache lookups (the installed-build lookup a registry open makes first, the offline answer, and the monotonic rule of a fetch) now see only records whose signed `abi_fingerprint` is the SDK's own, so a newer build of another fingerprint, installed by another dev SDK in the shared cache, is never returned or kept over this one's own, and is never removed or rewritten. So a dev build of a newer fingerprint no longer strands an older dev SDK until its consumers upgrade. Trust is unchanged (the signed predicate and the load checks decide), a listing never shows an alias, nothing records one, `list` and `where` are unchanged, and there is no option: both steps are the dev channel's alone, and the v1 contract and every production channel never take them. The rule is `docs/guides/fetch-v1.md` section 3, and the `dev-alias-*`, `resolve-installed-dev-alias-*` and `list-tags-dev-alias` conformance cases hold all four bindings to it.
|
|
12
17
|
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- A 2.0.0-dev SDK whose fingerprint no published build carries yet now fails closed with a precise message (#578). When every base answers its own alias 404 and the tag names a build signed for another fingerprint, `fetch` is `CHTYPES_ARTIFACT_UNPUBLISHED` (exit status 4): `no published build for this SDK's fingerprint <own fp>; newest published on this channel is <fp> (build <id>)`. It used to install that build, or report it already installed, and the lookup at open then answered `CHTYPES_ARTIFACT_MISSING` with advice to run `fetch`: a loop with no pointer to the cause. Nothing is downloaded or installed and the cache is unchanged. An alias that answers, a tag at the SDK's own fingerprint and the v1 contract are unchanged. All four bindings run the same fetch conformance cases, `fp-ahead-*`, and the rule is `docs/guides/fetch-v1.md` section 3.
|
|
21
|
+
|
|
13
22
|
## [1.1.0] — 2026-10-06
|
|
14
23
|
|
|
15
24
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: chtypes
|
|
3
|
-
Version: 2.0.0.
|
|
3
|
+
Version: 2.0.0.dev4
|
|
4
4
|
Summary: Python binding for the chtypes artifacts: ClickHouse's own type system, per version, behind the frozen chs_* C ABI
|
|
5
5
|
Project-URL: Homepage, https://github.com/wave-rf/chtypes
|
|
6
6
|
Project-URL: Repository, https://github.com/wave-rf/chtypes
|
|
@@ -22,6 +22,8 @@ Description-Content-Type: text/markdown
|
|
|
22
22
|
> **2.0.0-dev: UNSTABLE, staging only, not for production.** This is the ABI v2 development binding (public issue #511). It speaks ABI v2's unstable description, pins its dev fingerprint and refuses a library with any other ("update your dev SDK"). It fetches only from the staging dev channel (`https://registry-staging.wavehouse.dev/chtypes/v2-dev`) and trusts only the staging key; `CHTYPES_ARTIFACTS_URL`, `CHTYPES_TRUSTED_KEYS` and `CHTYPES_ALLOW_UNSIGNED`, and the `bases`, `trusted_keys` and `allow_unsigned` fetch options, are ignored, each with one warning; `--lock`, `--frozen` and `--update`, and the `frozen`, `lock_path`, `lock_write` and `update` options, are refused, because a dev build is replaceable and a superseded one expires after 14 days. Its cache is `${XDG_CACHE_HOME:-~/.cache}/chtypes/v2-dev`, or `<CHTYPES_CACHE>/v2-dev` under an explicit cache, which no 1.x SDK reads. A dev SDK prefers the newest build of its own fingerprint: it resolves `<tag>--fp-<its fingerprint>` first and the tag only when no such build exists, and its cache lookups ignore another dev SDK's builds in a shared cache, so a newer dev fingerprint never strands it (§3 of [`docs/guides/fetch-v1.md`](../docs/guides/fetch-v1.md)). Every vocabulary keeps a value it does not list as its `unknown(n)` member (`Outcome("x")`, whose `known` is `False`) instead of failing the document. The rules are r1 to r6 of [`docs/reference/abi-v2.md`](../docs/reference/abi-v2.md). For production, use the 1.x package: `pip install "chtypes<2"`.
|
|
23
23
|
>
|
|
24
24
|
> An explicit cache directory gets the `v2-dev` subroot whether it comes from `CHTYPES_CACHE` or from `FetchOptions(cache_dir=...)`: the layout is under `<cache_dir>/v2-dev`, never in the directory itself, so code that inspects or pre-populates a cache looks there; `chtypes.cache_root` and `chtypes.search_dirs` return the resolved paths. `CHTYPES_OFFLINE=1` is the environment twin of `FetchOptions(offline=True)` and `--offline`: the cache only, no request.
|
|
25
|
+
>
|
|
26
|
+
> <!-- remove-at-v2-lock -->v2-dev builds before the one that carries this contract (its release notice names it) can answer `ok` with `t` verdicts after a refused row. On those builds, when a body or block holds more than one row, treat every verdict as `d` if `errors` is non-empty.<!-- /remove-at-v2-lock -->
|
|
25
27
|
|
|
26
28
|
**If this row were inserted into this table on this ClickHouse version, what would happen?** chtypes answers with ClickHouse's own code: the real C++ type machinery, vendored per release into a native library behind the frozen `chs_*` C ABI and reached here through stdlib `ctypes`. Nothing semantic is reimplemented, so _"what does ClickHouse do with `256` into a `UInt8`?"_ is answered by ClickHouse rather than by a model of it. One peer binding among `{go, python, ts, rust}` — no language is privileged, and all four give one answer.
|
|
27
29
|
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
> **2.0.0-dev: UNSTABLE, staging only, not for production.** This is the ABI v2 development binding (public issue #511). It speaks ABI v2's unstable description, pins its dev fingerprint and refuses a library with any other ("update your dev SDK"). It fetches only from the staging dev channel (`https://registry-staging.wavehouse.dev/chtypes/v2-dev`) and trusts only the staging key; `CHTYPES_ARTIFACTS_URL`, `CHTYPES_TRUSTED_KEYS` and `CHTYPES_ALLOW_UNSIGNED`, and the `bases`, `trusted_keys` and `allow_unsigned` fetch options, are ignored, each with one warning; `--lock`, `--frozen` and `--update`, and the `frozen`, `lock_path`, `lock_write` and `update` options, are refused, because a dev build is replaceable and a superseded one expires after 14 days. Its cache is `${XDG_CACHE_HOME:-~/.cache}/chtypes/v2-dev`, or `<CHTYPES_CACHE>/v2-dev` under an explicit cache, which no 1.x SDK reads. A dev SDK prefers the newest build of its own fingerprint: it resolves `<tag>--fp-<its fingerprint>` first and the tag only when no such build exists, and its cache lookups ignore another dev SDK's builds in a shared cache, so a newer dev fingerprint never strands it (§3 of [`docs/guides/fetch-v1.md`](../docs/guides/fetch-v1.md)). Every vocabulary keeps a value it does not list as its `unknown(n)` member (`Outcome("x")`, whose `known` is `False`) instead of failing the document. The rules are r1 to r6 of [`docs/reference/abi-v2.md`](../docs/reference/abi-v2.md). For production, use the 1.x package: `pip install "chtypes<2"`.
|
|
4
4
|
>
|
|
5
5
|
> An explicit cache directory gets the `v2-dev` subroot whether it comes from `CHTYPES_CACHE` or from `FetchOptions(cache_dir=...)`: the layout is under `<cache_dir>/v2-dev`, never in the directory itself, so code that inspects or pre-populates a cache looks there; `chtypes.cache_root` and `chtypes.search_dirs` return the resolved paths. `CHTYPES_OFFLINE=1` is the environment twin of `FetchOptions(offline=True)` and `--offline`: the cache only, no request.
|
|
6
|
+
>
|
|
7
|
+
> <!-- remove-at-v2-lock -->v2-dev builds before the one that carries this contract (its release notice names it) can answer `ok` with `t` verdicts after a refused row. On those builds, when a body or block holds more than one row, treat every verdict as `d` if `errors` is non-empty.<!-- /remove-at-v2-lock -->
|
|
6
8
|
|
|
7
9
|
**If this row were inserted into this table on this ClickHouse version, what would happen?** chtypes answers with ClickHouse's own code: the real C++ type machinery, vendored per release into a native library behind the frozen `chs_*` C ABI and reached here through stdlib `ctypes`. Nothing semantic is reimplemented, so _"what does ClickHouse do with `256` into a `UInt8`?"_ is answered by ClickHouse rather than by a model of it. One peer binding among `{go, python, ts, rust}` — no language is privileged, and all four give one answer.
|
|
8
10
|
|
|
@@ -48,6 +48,7 @@ from importlib.metadata import version as _package_version
|
|
|
48
48
|
|
|
49
49
|
from ._abi2._vocab import (
|
|
50
50
|
EXPORT_NONE,
|
|
51
|
+
DeclinedTier,
|
|
51
52
|
DefaultKind,
|
|
52
53
|
DiscoverQueryParam,
|
|
53
54
|
DocFlags,
|
|
@@ -72,6 +73,7 @@ from .errors import (
|
|
|
72
73
|
CODE_CACHE_UNUSABLE,
|
|
73
74
|
CODE_SOURCE_FORBIDDEN,
|
|
74
75
|
CODE_SOURCE_INCOMPATIBLE,
|
|
76
|
+
CODE_SOURCE_RETIRED,
|
|
75
77
|
CODE_SOURCE_UNAUTHORIZED,
|
|
76
78
|
CODE_SOURCE_UNREACHABLE,
|
|
77
79
|
ArtifactCorruptError,
|
|
@@ -88,6 +90,7 @@ from .errors import (
|
|
|
88
90
|
SchemaError,
|
|
89
91
|
SourceForbiddenError,
|
|
90
92
|
SourceIncompatibleError,
|
|
93
|
+
SourceRetiredError,
|
|
91
94
|
SourceUnauthorizedError,
|
|
92
95
|
SourceUnreachableError,
|
|
93
96
|
UnsupportedError,
|
|
@@ -102,6 +105,7 @@ from .results import (
|
|
|
102
105
|
Capabilities,
|
|
103
106
|
Column,
|
|
104
107
|
Computed,
|
|
108
|
+
DeclinedSetting,
|
|
105
109
|
DiscoveredColumn,
|
|
106
110
|
Discovery,
|
|
107
111
|
EngineCell,
|
|
@@ -130,6 +134,7 @@ __all__ = [
|
|
|
130
134
|
"CODE_CACHE_UNUSABLE",
|
|
131
135
|
"CODE_SOURCE_FORBIDDEN",
|
|
132
136
|
"CODE_SOURCE_INCOMPATIBLE",
|
|
137
|
+
"CODE_SOURCE_RETIRED",
|
|
133
138
|
"CODE_SOURCE_UNAUTHORIZED",
|
|
134
139
|
"CODE_SOURCE_UNREACHABLE",
|
|
135
140
|
"EXPORT_NONE",
|
|
@@ -151,6 +156,8 @@ __all__ = [
|
|
|
151
156
|
"ChtypesError",
|
|
152
157
|
"Column",
|
|
153
158
|
"Computed",
|
|
159
|
+
"DeclinedSetting",
|
|
160
|
+
"DeclinedTier",
|
|
154
161
|
"DefaultKind",
|
|
155
162
|
"DiscoverQueryParam",
|
|
156
163
|
"DiscoveredColumn",
|
|
@@ -186,6 +193,7 @@ __all__ = [
|
|
|
186
193
|
"Source",
|
|
187
194
|
"SourceForbiddenError",
|
|
188
195
|
"SourceIncompatibleError",
|
|
196
|
+
"SourceRetiredError",
|
|
189
197
|
"SourceUnauthorizedError",
|
|
190
198
|
"SourceUnreachableError",
|
|
191
199
|
"Span",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GENERATED by scripts/abi-v1/gen.py --major 2 from spec/abi-v2/abi.json (CHS_ABI_FINGERPRINT sha256:
|
|
1
|
+
# GENERATED by scripts/abi-v1/gen.py --major 2 from spec/abi-v2/abi.json (CHS_ABI_FINGERPRINT sha256:28c7445ce6b5c6d0ae33177fd60eb7b3b5654a966c842b8d812aea622824dc72) — DO NOT EDIT # noqa: E501
|
|
2
2
|
"""The Python binding's generated ABI v2 layer: ctypes signatures, the handle
|
|
3
3
|
classes, the two-phase resolve functions and invoke_by_name(), the test-only
|
|
4
4
|
dispatcher the conformance suite drives from tests/fixtures/abi-v2/cases.json.
|
|
@@ -19,7 +19,7 @@ from dataclasses import dataclass, field
|
|
|
19
19
|
from . import _errmap
|
|
20
20
|
|
|
21
21
|
CHS_ABI_VERSION = 2
|
|
22
|
-
CHS_ABI_FINGERPRINT = "sha256:
|
|
22
|
+
CHS_ABI_FINGERPRINT = "sha256:28c7445ce6b5c6d0ae33177fd60eb7b3b5654a966c842b8d812aea622824dc72"
|
|
23
23
|
|
|
24
24
|
# The description's stability: "unstable" while this generation is being
|
|
25
25
|
# designed, so CHS_ABI_FINGERPRINT moves with every change, and "locked" after
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# GENERATED by scripts/abi-v1/gen.py --major 2 from spec/abi-v2/abi.json (CHS_ABI_FINGERPRINT sha256:
|
|
1
|
+
# GENERATED by scripts/abi-v1/gen.py --major 2 from spec/abi-v2/abi.json (CHS_ABI_FINGERPRINT sha256:28c7445ce6b5c6d0ae33177fd60eb7b3b5654a966c842b8d812aea622824dc72) — DO NOT EDIT # noqa: E501
|
|
2
2
|
"""spec/abi-v2/sdk.json's error-mapping tables, as references to the
|
|
3
3
|
public classes (python/src/chtypes/errors.py, re-exported by
|
|
4
4
|
python/src/chtypes/_abi2/_errors.py). Only the MAPPING is generated: the
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# GENERATED by scripts/abi-v1/gen.py --major 2 from spec/abi-v2/abi.json (CHS_ABI_FINGERPRINT sha256:
|
|
1
|
+
# GENERATED by scripts/abi-v1/gen.py --major 2 from spec/abi-v2/abi.json (CHS_ABI_FINGERPRINT sha256:28c7445ce6b5c6d0ae33177fd60eb7b3b5654a966c842b8d812aea622824dc72) — DO NOT EDIT # noqa: E501
|
|
2
2
|
"""The Python binding's generated vocabularies, from spec/abi-v2/abi.json: the C
|
|
3
3
|
enums (`Format`, `Status`), the document vocabularies (`Outcome`, `FilterOutcome`,
|
|
4
|
-
`Verdict`, `DefaultKind`, `MergeReason`, `Reason`, `Source`,
|
|
5
|
-
facts the description attaches to each value
|
|
6
|
-
`Source` is_stored, `Verdict.answered`), and the
|
|
7
|
-
this package keeps a copy of any of it.
|
|
4
|
+
`Verdict`, `DefaultKind`, `MergeReason`, `DeclinedTier`, `Reason`, `Source`,
|
|
5
|
+
`DiscoverQueryParam`) with the facts the description attaches to each value
|
|
6
|
+
(`Format.ch_name`, `Reason` lossy, `Source` is_stored, `Verdict.answered`), and the
|
|
7
|
+
`DocFlags` groups. No other file in this package keeps a copy of any of it.
|
|
8
8
|
|
|
9
9
|
Rule r3 (spec/abi-v2/docs.md): every vocabulary has an unknown(n) member, and a
|
|
10
10
|
value the description does not list reads as it, carrying the raw value, for that
|
|
@@ -249,6 +249,31 @@ class MergeReason(StrEnum):
|
|
|
249
249
|
return cls(text)
|
|
250
250
|
|
|
251
251
|
|
|
252
|
+
class DeclinedTier(StrEnum):
|
|
253
|
+
"""The WHERE-settings tier of a setting a server profile sets and this build's
|
|
254
|
+
filters do not honor in a WHERE, as a `DeclinedSetting` reports it."""
|
|
255
|
+
|
|
256
|
+
PREDICATE = "predicate"
|
|
257
|
+
PREDICATE_UNFLIPPED = "predicate-unflipped"
|
|
258
|
+
RESULT_CONTENT = "result-content"
|
|
259
|
+
|
|
260
|
+
@classmethod
|
|
261
|
+
def _missing_(cls, value: object) -> DeclinedTier | None:
|
|
262
|
+
return _unknown_str(cls, value)
|
|
263
|
+
|
|
264
|
+
@property
|
|
265
|
+
def known(self) -> bool:
|
|
266
|
+
"""Whether the description lists this value: False for exactly the unknown(n)
|
|
267
|
+
member an unlisted value reads as (rule r3)."""
|
|
268
|
+
return type(self)._value2member_map_.get(self._value_) is self
|
|
269
|
+
|
|
270
|
+
@classmethod
|
|
271
|
+
def of(cls, text: str) -> DeclinedTier:
|
|
272
|
+
"""Map a document's spelling. One the description does not list is kept as
|
|
273
|
+
this vocabulary's unknown(n) member, carrying it (rule r3)."""
|
|
274
|
+
return cls(text)
|
|
275
|
+
|
|
276
|
+
|
|
252
277
|
class DiscoverQueryParam(StrEnum):
|
|
253
278
|
"""A query parameter of the SQL `discover_query` returns, which the caller binds
|
|
254
279
|
when it runs the query."""
|
|
@@ -415,6 +440,7 @@ DESCRIBED_VOCABULARIES: Final[dict[str, type]] = {
|
|
|
415
440
|
"filter_verdict": Verdict,
|
|
416
441
|
"discover_query_param": DiscoverQueryParam,
|
|
417
442
|
"default_kind": DefaultKind,
|
|
443
|
+
"declined_tier": DeclinedTier,
|
|
418
444
|
}
|
|
419
445
|
|
|
420
446
|
|
|
@@ -28,7 +28,16 @@ import json
|
|
|
28
28
|
from collections.abc import Callable, Mapping
|
|
29
29
|
from typing import Any
|
|
30
30
|
|
|
31
|
-
from ._abi2._vocab import
|
|
31
|
+
from ._abi2._vocab import (
|
|
32
|
+
DeclinedTier,
|
|
33
|
+
DefaultKind,
|
|
34
|
+
FilterOutcome,
|
|
35
|
+
MergeReason,
|
|
36
|
+
Outcome,
|
|
37
|
+
Reason,
|
|
38
|
+
Source,
|
|
39
|
+
Verdict,
|
|
40
|
+
)
|
|
32
41
|
from .errors import ArtifactCorruptError, internal
|
|
33
42
|
from .results import (
|
|
34
43
|
AtMergeEntry,
|
|
@@ -37,6 +46,7 @@ from .results import (
|
|
|
37
46
|
Capabilities,
|
|
38
47
|
Column,
|
|
39
48
|
Computed,
|
|
49
|
+
DeclinedSetting,
|
|
40
50
|
DiscoveredColumn,
|
|
41
51
|
Discovery,
|
|
42
52
|
EngineCell,
|
|
@@ -493,11 +503,22 @@ def _string_map(obj: Mapping[str, Any], key: str, where: str) -> dict[str, str]
|
|
|
493
503
|
return out
|
|
494
504
|
|
|
495
505
|
|
|
506
|
+
def _declined_setting(obj: dict[str, Any], where: str) -> DeclinedSetting:
|
|
507
|
+
# An unlisted tier is its unknown(n): kept, never a failure (rule r3).
|
|
508
|
+
return DeclinedSetting(
|
|
509
|
+
name=_name(obj, "name", where),
|
|
510
|
+
tier=DeclinedTier.of(_text(obj, "tier", where)),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
|
|
496
514
|
def _server(obj: dict[str, Any], where: str) -> SchemaServer:
|
|
497
515
|
return SchemaServer(
|
|
498
516
|
timezone=_text(obj, "timezone", where),
|
|
499
517
|
settings=_string_map(obj, "settings", where) or {},
|
|
500
518
|
macros=_string_map(obj, "macros", where),
|
|
519
|
+
filter_declined_settings=_objects(
|
|
520
|
+
obj, "filter_declined_settings", where, _declined_setting
|
|
521
|
+
),
|
|
501
522
|
)
|
|
502
523
|
|
|
503
524
|
|
|
@@ -52,6 +52,7 @@ from typing import Final, Protocol
|
|
|
52
52
|
from chtypes._abi2._decls import CHS_ABI_FINGERPRINT
|
|
53
53
|
from chtypes._ocifetch import _constants as C
|
|
54
54
|
from chtypes._ocifetch._dsse import TrustedKey
|
|
55
|
+
from chtypes._ocifetch._errors import ArtifactUnpublishedError
|
|
55
56
|
|
|
56
57
|
__all__ = [
|
|
57
58
|
"ALIAS_SEPARATOR",
|
|
@@ -66,6 +67,7 @@ __all__ = [
|
|
|
66
67
|
"PinningRefusedError",
|
|
67
68
|
"abi",
|
|
68
69
|
"active",
|
|
70
|
+
"ahead_of_registry",
|
|
69
71
|
"alias_tag",
|
|
70
72
|
"allow_overrides_for_tests",
|
|
71
73
|
"channel_name",
|
|
@@ -274,6 +276,43 @@ def visible(predicate: object, channel: Channel | None = None) -> bool:
|
|
|
274
276
|
return fingerprint == f"sha256:{channel.own_fingerprint}"
|
|
275
277
|
|
|
276
278
|
|
|
279
|
+
def ahead_of_registry(
|
|
280
|
+
alias_absent: bool, predicate: object, channel: Channel | None = None
|
|
281
|
+
) -> None:
|
|
282
|
+
"""The dev channel's answer for an SDK whose fingerprint no published build
|
|
283
|
+
carries yet (docs/guides/fetch-v1.md §3; public issue #578): when every base
|
|
284
|
+
answered its own alias 404 (`alias_absent`) and the build the tag names is
|
|
285
|
+
signed for another fingerprint (`predicate`, the SIGNED predicate, the field
|
|
286
|
+
`visible` keys on), raise `ArtifactUnpublishedError`, the code a request no
|
|
287
|
+
build answers gets, naming both fingerprints. Nothing is installed and an
|
|
288
|
+
install of that build is never reported, because the lookup this SDK opens
|
|
289
|
+
through would refuse it. Returns in every other case: the alias answered,
|
|
290
|
+
the tag's build is this SDK's own, or the contract has no own fingerprint."""
|
|
291
|
+
channel = channel or active()
|
|
292
|
+
if not alias_absent or visible(predicate, channel):
|
|
293
|
+
return
|
|
294
|
+
raise ArtifactUnpublishedError(f"chtypes: {_ahead_message(channel.own_fingerprint, predicate)}")
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def _ahead_message(own: str, predicate: object) -> str:
|
|
298
|
+
"""`ahead_of_registry`'s message: "no published build for this SDK's
|
|
299
|
+
fingerprint <own>; newest published on this channel is <fp> (build <id>)",
|
|
300
|
+
each fingerprint 64 lowercase hex without its `sha256:` prefix, the
|
|
301
|
+
parenthesis dropped when the predicate names no build, and "unnamed" for a
|
|
302
|
+
predicate that names no fingerprint."""
|
|
303
|
+
fields = predicate if isinstance(predicate, dict) else {}
|
|
304
|
+
theirs = fields.get("abi_fingerprint")
|
|
305
|
+
theirs = theirs.removeprefix("sha256:") if isinstance(theirs, str) else ""
|
|
306
|
+
message = (
|
|
307
|
+
f"no published build for this SDK's fingerprint {own}; "
|
|
308
|
+
f"newest published on this channel is {theirs or 'unnamed'}"
|
|
309
|
+
)
|
|
310
|
+
build = fields.get("build")
|
|
311
|
+
if isinstance(build, str) and build:
|
|
312
|
+
message += f" (build {build})"
|
|
313
|
+
return message
|
|
314
|
+
|
|
315
|
+
|
|
277
316
|
def use_dev_channel_for_tests() -> Callable[[], None]:
|
|
278
317
|
"""Make this TEST run speak the dev channel exactly as a user's process does
|
|
279
318
|
(undoing either function above, for a test of the dev channel itself).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Code generated by scripts/fetch-v1/gen-constants.py from
|
|
2
2
|
# spec/fetch-v1/constants.json. DO NOT EDIT.
|
|
3
|
-
# Source sha256:
|
|
3
|
+
# Source sha256: 4554956faeb154fc324a6120b7b35976222c6bc8ecbce7fd0147502e3073611d
|
|
4
4
|
"""The v1 fetch constants, generated: see docs/guides/fetch-v1.md."""
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
@@ -83,6 +83,7 @@ RETRY_AFTER_STATUSES: Final[tuple[int, ...]] = (429, 503)
|
|
|
83
83
|
RETRY_AFTER_OVER_BUDGET: Final[str] = "refuse"
|
|
84
84
|
DIGEST_404_POLICY: Final[str] = "next_base_then_retry_on_last"
|
|
85
85
|
TAG_404_POLICY: Final[str] = "next_base_then_unpublished"
|
|
86
|
+
RETIRED_STATUSES: Final[tuple[int, ...]] = (410,)
|
|
86
87
|
|
|
87
88
|
CONNECT_TIMEOUT_S: Final[float] = 30.0
|
|
88
89
|
IDLE_READ_TIMEOUT_S: Final[float] = 60.0
|
|
@@ -95,6 +96,8 @@ MAX_REFERRERS: Final[int] = 16
|
|
|
95
96
|
MAX_REDIRECTS: Final[int] = 5
|
|
96
97
|
MAX_UNPACKED_BYTES: Final[int] = 4294967296
|
|
97
98
|
ZSTD_WINDOW_LOG_MAX: Final[int] = 27
|
|
99
|
+
RETIRED_BODY_MAX_BYTES: Final[int] = 65536
|
|
100
|
+
RETIRED_MESSAGE_MAX_CODE_POINTS: Final[int] = 256
|
|
98
101
|
|
|
99
102
|
CACHE_ROOT_TEMPLATE: Final[str] = "${XDG_CACHE_HOME:-$HOME/.cache}/chtypes/v1"
|
|
100
103
|
SYSTEM_CACHE_DIRS: Final[tuple[str, ...]] = ("/usr/local/share/chtypes/v1", "/opt/chtypes/v1")
|
|
@@ -122,4 +125,5 @@ ERROR_EXIT_CODES: Final[dict[str, int]] = {
|
|
|
122
125
|
"CHTYPES_SOURCE_INCOMPATIBLE": 7,
|
|
123
126
|
"CHTYPES_ARTIFACT_INCOMPATIBLE": 8,
|
|
124
127
|
"CHTYPES_CACHE_UNUSABLE": 9,
|
|
128
|
+
"CHTYPES_SOURCE_RETIRED": 10,
|
|
125
129
|
}
|
|
@@ -38,6 +38,7 @@ from chtypes._ocifetch._errors import (
|
|
|
38
38
|
ArtifactUntrustedError,
|
|
39
39
|
FetchError,
|
|
40
40
|
SourceForbiddenError,
|
|
41
|
+
SourceRetiredError,
|
|
41
42
|
SourceUnauthorizedError,
|
|
42
43
|
SourceUnreachableError,
|
|
43
44
|
)
|
|
@@ -49,6 +50,7 @@ from chtypes._ocifetch._http import (
|
|
|
49
50
|
ForbiddenHttpError,
|
|
50
51
|
NotFoundHttpError,
|
|
51
52
|
OversizeHttpError,
|
|
53
|
+
RetiredHttpError,
|
|
52
54
|
RetryPolicy,
|
|
53
55
|
TransportError,
|
|
54
56
|
UnauthorizedHttpError,
|
|
@@ -440,7 +442,7 @@ def _find_verified_signature(
|
|
|
440
442
|
bases, ref.digest, policy=policy, retry=retry
|
|
441
443
|
)
|
|
442
444
|
blob_desc = manifest_single_layer(referrer_doc, expected_media_type=C.MEDIA_TYPE_BUNDLE)
|
|
443
|
-
except ArtifactCorruptError:
|
|
445
|
+
except (ArtifactCorruptError, RetiredHttpError):
|
|
444
446
|
raise
|
|
445
447
|
except (TransportError, FetchError):
|
|
446
448
|
continue
|
|
@@ -458,7 +460,7 @@ def _find_verified_signature(
|
|
|
458
460
|
with open(bundle_path, "rb") as f:
|
|
459
461
|
bundle_json = json.loads(f.read())
|
|
460
462
|
verified = verify_bundle(bundle_json, trusted_keys)
|
|
461
|
-
except ArtifactCorruptError:
|
|
463
|
+
except (ArtifactCorruptError, RetiredHttpError):
|
|
462
464
|
raise
|
|
463
465
|
except (TransportError, FetchError, json.JSONDecodeError):
|
|
464
466
|
continue
|
|
@@ -698,7 +700,7 @@ def _ensure_floating(
|
|
|
698
700
|
cache_root_path = roots[0]
|
|
699
701
|
scratch_root = _scratch_root(cache_root_path)
|
|
700
702
|
|
|
701
|
-
index_doc, index_bytes, index_digest = fetch_manifest_by_tag(
|
|
703
|
+
index_doc, index_bytes, index_digest, alias_absent = fetch_manifest_by_tag(
|
|
702
704
|
bases,
|
|
703
705
|
request.spelling,
|
|
704
706
|
policy=policy,
|
|
@@ -711,6 +713,10 @@ def _ensure_floating(
|
|
|
711
713
|
existing_dir = unpacked_dir_for(cache_root_path, manifest_hex)
|
|
712
714
|
existing_record = read_verified_record(existing_dir)
|
|
713
715
|
if existing_record is not None and existing_record.platform == platform_key:
|
|
716
|
+
# An install of another fingerprint's build, reached through the tag
|
|
717
|
+
# because the registry has none at this SDK's own, is never reported
|
|
718
|
+
# installed (public issue #578): refused before the cache is touched.
|
|
719
|
+
_channel.ahead_of_registry(alias_absent, existing_record.predicate)
|
|
714
720
|
# A NEWER build within the request, installed beside it, is still the
|
|
715
721
|
# answer ("monotonic-warning", docs/guides/fetch-v1.md §9).
|
|
716
722
|
newer = _newer_installed(
|
|
@@ -801,6 +807,12 @@ def _ensure_floating(
|
|
|
801
807
|
signed_by = verified.signed_by
|
|
802
808
|
|
|
803
809
|
_check_predicate_matches_request(predicate, platform_key, request.spelling)
|
|
810
|
+
if found is not None:
|
|
811
|
+
# An SDK ahead of the registry (public issue #578): the alias for its
|
|
812
|
+
# own fingerprint answered 404 on every base, and the tag's build is
|
|
813
|
+
# signed for another. Refused from the signed statement, before the
|
|
814
|
+
# layer is requested, so nothing is downloaded or installed.
|
|
815
|
+
_channel.ahead_of_registry(alias_absent, predicate)
|
|
804
816
|
newer = _newer_installed(roots, platform_key, predicate, request.spelling)
|
|
805
817
|
if newer is not None:
|
|
806
818
|
newer_dir, newer_record, warning = newer
|
|
@@ -983,6 +995,8 @@ def _translate_transport_error(e: TransportError) -> FetchError:
|
|
|
983
995
|
return SourceForbiddenError(f"chtypes: {e}")
|
|
984
996
|
if isinstance(e, OversizeHttpError):
|
|
985
997
|
return ArtifactCorruptError(f"chtypes: {e}")
|
|
998
|
+
if isinstance(e, RetiredHttpError):
|
|
999
|
+
return SourceRetiredError(f"chtypes: {e}")
|
|
986
1000
|
if isinstance(e, UnreachableHttpError):
|
|
987
1001
|
return SourceUnreachableError(f"chtypes: {e}", retryable=getattr(e, "retryable", True))
|
|
988
1002
|
return SourceUnreachableError(f"chtypes: {e}")
|
|
@@ -1368,7 +1382,9 @@ def _fetch_signed_impl(repository: str, ref: str, predicate_type: str, options:
|
|
|
1368
1382
|
doc, _raw = fetch_manifest_by_digest(bases, ref, policy=policy, retry=retry)
|
|
1369
1383
|
manifest_digest = ref
|
|
1370
1384
|
else:
|
|
1371
|
-
doc, _raw, manifest_digest = fetch_manifest_by_tag(
|
|
1385
|
+
doc, _raw, manifest_digest, _alias_absent = fetch_manifest_by_tag(
|
|
1386
|
+
bases, ref, policy=policy, retry=retry
|
|
1387
|
+
)
|
|
1372
1388
|
|
|
1373
1389
|
layer_desc = manifest_single_layer(doc)
|
|
1374
1390
|
found = _find_verified_signature(
|
|
@@ -1466,6 +1482,8 @@ def _fetch_goldens(
|
|
|
1466
1482
|
retry=retry,
|
|
1467
1483
|
max_bytes=C.MAX_UNPACKED_BYTES,
|
|
1468
1484
|
)
|
|
1485
|
+
except RetiredHttpError:
|
|
1486
|
+
raise
|
|
1469
1487
|
except (TransportError, FetchError) as e:
|
|
1470
1488
|
first_failure = first_failure or e
|
|
1471
1489
|
continue
|
|
@@ -1580,6 +1598,8 @@ def _verify_goldens_signature(
|
|
|
1580
1598
|
except ArtifactCorruptError as e:
|
|
1581
1599
|
failure = failure or e
|
|
1582
1600
|
continue
|
|
1601
|
+
except RetiredHttpError:
|
|
1602
|
+
raise
|
|
1583
1603
|
except (TransportError, FetchError, json.JSONDecodeError):
|
|
1584
1604
|
continue
|
|
1585
1605
|
finally:
|
|
@@ -5,7 +5,7 @@ Scoped to `chtypes._ocifetch`: the stable, public exception types live in
|
|
|
5
5
|
imports from or edits. A future switch lane decides how (or whether) these
|
|
6
6
|
become public types; until then every name here is private.
|
|
7
7
|
|
|
8
|
-
Every exception carries a `.code` string from one of the
|
|
8
|
+
Every exception carries a `.code` string from one of the twelve codes
|
|
9
9
|
`spec/fetch-v1/constants.json`'s `errors` map assigns an exit status to
|
|
10
10
|
(the generated `ERROR_EXIT_CODES` table), so a CLI added later needs no
|
|
11
11
|
second mapping — it is the same lookup v0's `__main__.py` does today.
|
|
@@ -30,6 +30,7 @@ __all__ = [
|
|
|
30
30
|
"CODE_CACHE_UNUSABLE",
|
|
31
31
|
"CODE_SOURCE_FORBIDDEN",
|
|
32
32
|
"CODE_SOURCE_INCOMPATIBLE",
|
|
33
|
+
"CODE_SOURCE_RETIRED",
|
|
33
34
|
"CODE_SOURCE_UNAUTHORIZED",
|
|
34
35
|
"CODE_SOURCE_UNREACHABLE",
|
|
35
36
|
"ArtifactCorruptError",
|
|
@@ -41,6 +42,7 @@ __all__ = [
|
|
|
41
42
|
"FetchError",
|
|
42
43
|
"SourceForbiddenError",
|
|
43
44
|
"SourceIncompatibleError",
|
|
45
|
+
"SourceRetiredError",
|
|
44
46
|
"SourceUnauthorizedError",
|
|
45
47
|
"SourceUnreachableError",
|
|
46
48
|
]
|
|
@@ -55,6 +57,7 @@ CODE_SOURCE_UNAUTHORIZED = "CHTYPES_SOURCE_UNAUTHORIZED"
|
|
|
55
57
|
CODE_SOURCE_FORBIDDEN = "CHTYPES_SOURCE_FORBIDDEN"
|
|
56
58
|
CODE_SOURCE_INCOMPATIBLE = "CHTYPES_SOURCE_INCOMPATIBLE"
|
|
57
59
|
CODE_CACHE_UNUSABLE = "CHTYPES_CACHE_UNUSABLE"
|
|
60
|
+
CODE_SOURCE_RETIRED = "CHTYPES_SOURCE_RETIRED"
|
|
58
61
|
|
|
59
62
|
_CODES_USED_HERE = (
|
|
60
63
|
CODE_ARTIFACT_MISSING,
|
|
@@ -67,6 +70,7 @@ _CODES_USED_HERE = (
|
|
|
67
70
|
CODE_SOURCE_FORBIDDEN,
|
|
68
71
|
CODE_SOURCE_INCOMPATIBLE,
|
|
69
72
|
CODE_CACHE_UNUSABLE,
|
|
73
|
+
CODE_SOURCE_RETIRED,
|
|
70
74
|
)
|
|
71
75
|
|
|
72
76
|
# A drift guard, cheaper than a test: every code this module raises must be
|
|
@@ -187,3 +191,13 @@ class CacheUnusableError(FetchError):
|
|
|
187
191
|
self.path = path
|
|
188
192
|
self.reason = reason
|
|
189
193
|
self.os_error = os_error
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class SourceRetiredError(FetchError):
|
|
197
|
+
"""The source answered 410 Gone: a retired repository, which is permanent,
|
|
198
|
+
so the request was never retried and never sent to the next base
|
|
199
|
+
(docs/guides/fetch-v1.md §2, "A retired repository"; public issue #571).
|
|
200
|
+
The message names the URL that answered and carries the registry's own
|
|
201
|
+
message, made safe to print."""
|
|
202
|
+
|
|
203
|
+
code = CODE_SOURCE_RETIRED
|
|
@@ -29,6 +29,7 @@ from email.utils import parsedate_to_datetime
|
|
|
29
29
|
from urllib.parse import urljoin, urlsplit, urlunsplit
|
|
30
30
|
|
|
31
31
|
from chtypes._ocifetch import _constants as C
|
|
32
|
+
from chtypes._ocifetch._retired import retired_text
|
|
32
33
|
|
|
33
34
|
__all__ = [
|
|
34
35
|
"USER_AGENT",
|
|
@@ -38,6 +39,7 @@ __all__ = [
|
|
|
38
39
|
"HttpResponse",
|
|
39
40
|
"NotFoundHttpError",
|
|
40
41
|
"OversizeHttpError",
|
|
42
|
+
"RetiredHttpError",
|
|
41
43
|
"RetryPolicy",
|
|
42
44
|
"TransportError",
|
|
43
45
|
"UnauthorizedHttpError",
|
|
@@ -120,6 +122,13 @@ class OversizeHttpError(TransportError):
|
|
|
120
122
|
"""A response body exceeded the caller's declared size cap."""
|
|
121
123
|
|
|
122
124
|
|
|
125
|
+
class RetiredHttpError(TransportError):
|
|
126
|
+
"""A retired repository (`RETIRED_STATUSES`, a 410; docs/guides/fetch-v1.md
|
|
127
|
+
§2): permanent, so never retried and never a reason to try the next base.
|
|
128
|
+
Its text names the URL that answered and carries the registry's message,
|
|
129
|
+
made safe to print (`_retired.retired_message`)."""
|
|
130
|
+
|
|
131
|
+
|
|
123
132
|
class Clock:
|
|
124
133
|
"""The real wall clock. Tests inject a fake with the same interface so
|
|
125
134
|
retry cases run instantly and sleeps are asserted exactly."""
|
|
@@ -228,7 +237,16 @@ def _single_request(
|
|
|
228
237
|
)
|
|
229
238
|
except urllib.error.HTTPError as e:
|
|
230
239
|
try:
|
|
231
|
-
|
|
240
|
+
if e.code in C.RETIRED_STATUSES:
|
|
241
|
+
# Only the registry's message is wanted from a retired
|
|
242
|
+
# repository's answer: at most RETIRED_BODY_MAX_BYTES of it,
|
|
243
|
+
# and a body that fails part way is no body.
|
|
244
|
+
try:
|
|
245
|
+
body = e.read(C.RETIRED_BODY_MAX_BYTES)
|
|
246
|
+
except (OSError, ValueError, AttributeError):
|
|
247
|
+
body = b""
|
|
248
|
+
else:
|
|
249
|
+
body = _read_capped(e, max_bytes) if e.code not in _REDIRECT_CODES else b""
|
|
232
250
|
finally:
|
|
233
251
|
e.close()
|
|
234
252
|
return HttpResponse(status=e.code, headers=dict(e.headers or {}), body=body, url=url)
|
|
@@ -380,6 +398,11 @@ def _http_get_once(
|
|
|
380
398
|
headers.pop("Authorization", None)
|
|
381
399
|
continue
|
|
382
400
|
|
|
401
|
+
if resp.status in C.RETIRED_STATUSES:
|
|
402
|
+
# A retired repository: permanent, never retried, and the
|
|
403
|
+
# exception ends fetch_from_bases's loop over bases.
|
|
404
|
+
raise RetiredHttpError(retired_text(current_url, resp.status, resp.body))
|
|
405
|
+
|
|
383
406
|
if resp.status == 401:
|
|
384
407
|
if not tried_anon_flow and not policy.token:
|
|
385
408
|
challenge = resp.headers.get("WWW-Authenticate") or resp.headers.get(
|
|
@@ -523,6 +546,10 @@ def fetch_from_bases(
|
|
|
523
546
|
404, some unreachable — the outcome follows the LAST base tried, since
|
|
524
547
|
bases are an explicit preference order and the last one is the final
|
|
525
548
|
word a caller configured.
|
|
549
|
+
|
|
550
|
+
In every mode a retired repository (`RetiredHttpError`, a 410) ends the
|
|
551
|
+
loop on the base that answered it: it is permanent, never a reason to try
|
|
552
|
+
the next base, and in `alias` mode never a reason to fall back to the tag.
|
|
526
553
|
"""
|
|
527
554
|
if not bases:
|
|
528
555
|
raise UnreachableHttpError("no base URLs configured")
|
|
@@ -249,15 +249,19 @@ def fetch_manifest_by_tag(
|
|
|
249
249
|
retry: RetryPolicy,
|
|
250
250
|
max_bytes: int = C.MANIFEST_MAX_BYTES,
|
|
251
251
|
alias: str | None = None,
|
|
252
|
-
) -> tuple[dict, bytes, str]:
|
|
253
|
-
"""GET manifests/<tag>; returns (doc, raw_bytes, resolved_digest).
|
|
252
|
+
) -> tuple[dict, bytes, str, bool]:
|
|
253
|
+
"""GET manifests/<tag>; returns (doc, raw_bytes, resolved_digest, alias_absent).
|
|
254
254
|
|
|
255
255
|
With `alias` (the dev channel's `<tag>--fp-<fingerprint>`, from
|
|
256
256
|
`_channel.alias_tag`), GET manifests/<alias> first, and the tag only when
|
|
257
257
|
every base answered the alias 404 (docs/guides/fetch-v1.md §3); any other
|
|
258
258
|
failure of the alias request is raised as it is. What is returned is then
|
|
259
|
-
trusted exactly as the tag's own answer would be.
|
|
259
|
+
trusted exactly as the tag's own answer would be. `alias_absent` reports
|
|
260
|
+
that fallback: the alias was asked for and every base answered it 404, so
|
|
261
|
+
the registry has no build at this SDK's fingerprint, and the build the tag
|
|
262
|
+
names is checked against it (`_channel.ahead_of_registry`)."""
|
|
260
263
|
accept = (C.MEDIA_TYPE_INDEX, C.MEDIA_TYPE_MANIFEST)
|
|
264
|
+
alias_absent = False
|
|
261
265
|
if alias is not None:
|
|
262
266
|
try:
|
|
263
267
|
doc, resp = get_json(
|
|
@@ -270,9 +274,9 @@ def fetch_manifest_by_tag(
|
|
|
270
274
|
retry=retry,
|
|
271
275
|
)
|
|
272
276
|
except AliasNotFoundError:
|
|
273
|
-
|
|
277
|
+
alias_absent = True
|
|
274
278
|
else:
|
|
275
|
-
return doc, resp.body, f"sha256:{hashlib.sha256(resp.body).hexdigest()}"
|
|
279
|
+
return doc, resp.body, f"sha256:{hashlib.sha256(resp.body).hexdigest()}", False
|
|
276
280
|
doc, resp = get_json(
|
|
277
281
|
bases,
|
|
278
282
|
f"/manifests/{tag}",
|
|
@@ -283,7 +287,7 @@ def fetch_manifest_by_tag(
|
|
|
283
287
|
retry=retry,
|
|
284
288
|
)
|
|
285
289
|
digest = f"sha256:{hashlib.sha256(resp.body).hexdigest()}"
|
|
286
|
-
return doc, resp.body, digest
|
|
290
|
+
return doc, resp.body, digest, alias_absent
|
|
287
291
|
|
|
288
292
|
|
|
289
293
|
def fetch_blob_to_path(
|