-
Notifications
You must be signed in to change notification settings - Fork 0
XDE-85: registry compiled-core client (JSON, semver, read bearer) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Контракт клиента skillget-manager ↔ registry HTTP API | ||
|
|
||
| Канон спецификации сервера: [`docs/registry-api.md`](https://github.com/getskillpack/registry/blob/main/docs/registry-api.md) (раздел **Compiled core**). Этот документ фиксирует поведение библиотеки `github.com/getskillpack/skillget-manager` как **скомпилированного клиента**. | ||
|
|
||
| ## Переменные окружения | ||
|
|
||
| | Переменная | Назначение | | ||
| |------------|------------| | ||
| | `SKILLGET_REGISTRY_URL` | Базовый URL API **без** завершающего `/`: `{origin}/api/v1`. Имеет приоритет. | | ||
| | `SKPKG_REGISTRY_URL` | Устаревший алиас для базы API. | | ||
| | `SKILLGET_REGISTRY_READ_TOKEN` | Bearer для **GET** к `/api/v1/*` и для **GET** по `archive_url`, если оператор реестра включил `REGISTRY_READ_TOKEN`. | | ||
| | `SKILLGET_REGISTRY_TOKEN` | Bearer для **записи** (`POST /skills`, `DELETE …/versions/…`). | | ||
| | `SKILLGET_TOKEN` | Устаревший алиас для токена записи. | | ||
|
|
||
| Если задан только `SKILLGET_REGISTRY_READ_TOKEN`, анонимные запросы к API не выполняются: чтение идёт с этим Bearer. Если `SKILLGET_REGISTRY_READ_TOKEN` пуст, для чтения используется тот же токен, что и для записи (`SKILLGET_REGISTRY_TOKEN` / `SKILLGET_TOKEN`), если он задан — это упрощает сценарий «один секрет на приватный реестр». | ||
|
|
||
| Публичный реестр по умолчанию: `https://registry.skpkg.org/api/v1` (без обязательных токенов для чтения). | ||
|
|
||
| ## HTTP: маршруты и коды | ||
|
|
||
| Пути ниже относительны к базе из `SKILLGET_REGISTRY_URL`. | ||
|
|
||
| | Действие в библиотеке | Метод и путь | Успех | Ошибки (ожидания клиента) | | ||
| |------------------------|--------------|-------|---------------------------| | ||
| | `SearchSkills` | `GET /skills?…` | `200` + JSON | `401` при read-token на сервере | | ||
| | `ResolveInstallTarget` (без pin) | `GET /skills/{name}` | `200` + JSON detail | `404`, `401` | | ||
| | `ResolveInstallTarget` (все случаи) | `GET /skills/{name}/versions/{version}` | `200` + JSON version | `404`, **`410`** после yank, `401` | | ||
| | `PublishSkill` | `POST /skills` (multipart `manifest` + `archive`) | **`201`** пустое тело | `400`, `401`, `409`, `503` без write token | | ||
| | (сервер) yank | `DELETE /skills/{name}/versions/{version}` | **`204`** | `401`, `404` | | ||
|
|
||
| Тела ошибок reference-сервера — короткий `text/plain` (не JSON). Сообщения об ошибках в Go дополняются подсказками (`registry_errors.go`). | ||
|
|
||
| ## JSON: формы ответов | ||
|
|
||
| - **Список** `GET /skills` — объект с полями `data[]`, `meta` (`total`, `limit`, `offset`). Элементы `data` содержат как минимум `name`, `latest_version`, `created_at`, `description`, `author` (как в спецификации). | ||
| - **Деталь скилла** `GET /skills/{name}` — поля `name`, `description`, `author`, `created_at`, **`versions`** — объект, ключи = semver-строки версий, значения: `manifest`, `checksum` (`sha256:` + 64 hex), `archive_url`, `published_at`, `yanked`. | ||
| - **Версия** `GET /skills/{name}/versions/{version}` — `name`, `version`, `manifest`, `archive_url`, `checksum`. | ||
|
|
||
| Библиотека **не** использует несуществующее в каноне поле `latest_version` на ответе `GET /skills/{name}`: для установки без pin выбирается **наибольшая по semver** неснятая (`yanked: false`) версия из `versions`, в духе логики `latestNonYanked` в reference store. | ||
|
|
||
| ## Публикация и архив | ||
|
|
||
| - `PublishSkill`: `multipart/form-data`, поля `manifest` (JSON-строка) и `archive` (файл `.tar.gz`), заголовок `Authorization: Bearer <write token>`. | ||
| - `DownloadSkillArchive`: GET по абсолютному `archive_url` из ответа версии; при непустом `RegistryReadBearer()` добавляется тот же `Authorization`, что и к API (для приватных `/downloads/*`). | ||
|
|
||
| ## Проверка целостности | ||
|
|
||
| Если в метаданных версии присутствует `checksum` в формате `sha256:<64 hex>`, после скачивания выполняется сверка SHA-256 с содержимым файла. | ||
|
|
||
| ## Соответствие ENGINEERING_REQUIREMENTS_SKPKG.md | ||
|
|
||
| Файл `plans/ENGINEERING_REQUIREMENTS_SKPKG.md` в onboarding/CTO workspace не входит в этот репозиторий. Стек менеджера — **Go**, контракт с реестром — **HTTP + JSON** по канону выше; расхождения с инженерным чеклистом фиксируются в рабочих тикетах Paperclip (см. раздел в `registry-api.md`). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| module github.com/getskillpack/skillget-manager | ||
|
|
||
| go 1.22 | ||
| go 1.22.0 | ||
|
|
||
| toolchain go1.22.12 | ||
|
|
||
| require golang.org/x/mod v0.23.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= | ||
| golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,10 @@ import ( | |
| "context" | ||
| "fmt" | ||
| "net/url" | ||
| "sort" | ||
| "strings" | ||
|
|
||
| "golang.org/x/mod/semver" | ||
| ) | ||
|
|
||
| // NameVersion holds a parsed skill spec "name" or "name@version". | ||
|
|
@@ -48,34 +51,32 @@ func ResolveInstallTarget(ctx context.Context, spec string) (*VersionDetail, err | |
| return &vd, nil | ||
| } | ||
|
|
||
| // pickInstallableVersion chooses a version for an unpinned install. | ||
| // Prefers registry latest_version when present and not marked yanked in versions[]; | ||
| // otherwise the first non-yanked entry in versions (registry order). | ||
| // pickInstallableVersion chooses the highest semver among non-yanked versions in the | ||
| // skill detail map, matching reference registry logic (see getskillpack/registry filestore). | ||
| func pickInstallableVersion(d SkillDetail) string { | ||
| if d.LatestVersion != nil { | ||
| candidate := strings.TrimSpace(*d.LatestVersion) | ||
| if candidate != "" && !versionMarkedYanked(d, candidate) { | ||
| return candidate | ||
| } | ||
| if len(d.Versions) == 0 { | ||
| return "" | ||
| } | ||
| for _, v := range d.Versions { | ||
| if v.IsYanked { | ||
| var keys []string | ||
| for v, info := range d.Versions { | ||
| v = strings.TrimSpace(v) | ||
| if v == "" || info.Yanked { | ||
| continue | ||
| } | ||
| if v.Version != "" { | ||
| return v.Version | ||
| } | ||
| keys = append(keys, v) | ||
| } | ||
| return "" | ||
| if len(keys) == 0 { | ||
| return "" | ||
| } | ||
| sort.Slice(keys, func(i, j int) bool { | ||
| return semver.Compare(canonicalSemver(keys[i]), canonicalSemver(keys[j])) < 0 | ||
| }) | ||
| return keys[len(keys)-1] | ||
|
Comment on lines
+60
to
+74
|
||
| } | ||
|
|
||
| // versionMarkedYanked reports whether v appears in d.Versions with is_yanked true. | ||
| // If v is not listed, returns false (trust latest_version from the registry). | ||
| func versionMarkedYanked(d SkillDetail, v string) bool { | ||
| for _, row := range d.Versions { | ||
| if row.Version == v { | ||
| return row.IsYanked | ||
| } | ||
| func canonicalSemver(v string) string { | ||
| if !strings.HasPrefix(v, "v") { | ||
| return "v" + v | ||
| } | ||
| return false | ||
| return v | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unconditionally adds the registry bearer to whatever absolute
archive_urlis returned. Ifarchive_urlcan point to a different host (e.g., CDN/S3 presigned URLs), this can leak read/write tokens cross-origin. Consider only attachingAuthorizationwhen the archive URL host matches the registry host (or when an explicit allowlist/opt-in env var is set).