feat: cache NAR upload + interactive CLI (#261) - #301
Conversation
Replace the curl-only script with a single-node test (no worker, no test store) that exercises the management + cache-NAR API surface both directly and via the gradient CLI: auth, user/keys, orgs, projects, workers, caches, and the new cache NAR upload/list/show/stats/delete flow (synthetic NAR, no nix needed). Build-dependent endpoints are checked for empty/not-found behaviour. OIDC/SMTP/forge/proto/build-request endpoints remain covered by their dedicated tests.
|
Reworked the
|
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
|
/gradient run checks.x86_64-linux.gradient-api |
Add a second user and exercise org/cache membership (add/re-role/remove), project transfer to a second org, custom cache-role lifecycle, HTTP upstream CRUD, and org subscription remove/restore. Document the NixOS API surface test in docs/src/tests.md.
|
/gradient run checks.x86_64-linux.gradient-api |
…on checks Negative coverage: duplicate org/project/cache/role/cache-role/api-key/member/ subscription creates (enveloped 409), reserved project name and empty key permission mask (enveloped 400). New permissions phase logs in the second user and asserts View-role denials (403) on settings edit, project create, member add, and org delete, then confirms Admin promotion unlocks them.
|
/gradient run checks.x86_64-linux.gradient-api |
Closes #261.
Part A — Cache NAR upload
Push local store paths or raw
.narfiles to a Gradient cache.gradient_core::cache::ingest):ingest_nar(blob write +cached_pathupsert + signature placeholders) andingest_metadata_only, parameterised bySignTargets::{OrgCaches, Cache, None}. The workerNarUploadedpath now delegates itscached_path/signature work here (blob write + abort-on-failure stays worker-side, preserving the storage→abort / DB→warn split).derivation_outputlinking stays worker-only.POST /api/v1/caches/{cache}/nars: multipart (narinfoJSON +narbytes), requireswriteStore, validates byte length vs declaredfile_size, signs asynchronously via the existing sweep, writes an audit row. Per-route body limitGRADIENT_MAX_NAR_UPLOAD_SIZE(default 512 MiB) — added toLimitsArgs, the nix module, and docs.gradient cache upload:--nar-file <f.nar> --narinfo <f.narinfo> <cache>.nixCargo feature, default off): resolves store paths via harmoniaLocalNixStore, dumps NARs,--full-closurewalks the runtime closure.nar_upload, OpenAPI, docs, tests.Part B — Interactive CLI (ratatui)
Per-command
-i/--interactiveflags (no-op under--json):gradient cache nar list -i— searchable/scrollable NAR browser.gradient builds graph <id> -i— nix-tree-style collapsible dependency-graph browser (newbuildscommand group).gradient builds log <id> -i— less-style log pager (scroll, follow-tail,/search).Panic-safe terminal restore; view-models are unit-tested independently of the terminal.
Tests
core::cache::ingest(mock DB + temp store),webcaches_upload(auth surface; mutation cases#[ignore]per the repo's MockDatabase precedent), connectornar_upload(wiremock), CLI narinfo parser,cache uploadintegration (assert_cmd), and TUI view-model tests. Catalogued indocs/src/tests.md. Verified locally withcargo clippy(backend workspace + CLI both feature sets, all targets) — clean; full suite runs in CI.Follow-ups (deliberately out of scope)
--full-closureissuesquery_path_infotwice per path (BFS + metadata); collapse into one pass.