From a3c08e40936ef3c9142f8ef7e8d939d23bf5c116 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Sun, 15 Nov 2026 13:43:05 -0600 Subject: [PATCH 1/2] fix(id): apply formatting for nix flake checks Fixes #8904 --- pkgs/id/WEB.md | 46 +-- pkgs/id/benches/world_bench.rs | 3 +- pkgs/id/crates/id-cli/src/commands/put.rs | 1 - .../crates/id-directory/src/directory_auth.rs | 23 +- pkgs/id/crates/id-native-shell/Cargo.toml | 4 +- pkgs/id/crates/id-sync/Cargo.toml | 4 +- pkgs/id/crates/id-sync/src/transfer.rs | 2 +- .../id-web/src/markdown/parse_helpers.rs | 4 +- .../examples/roc-import-policy/fixtures.json | 303 +++++++++++++++++- pkgs/id/hosted-worker/src/routing.ts | 5 +- pkgs/id/hosted-worker/src/user-do.ts | 33 +- pkgs/id/hosted-worker/test/blobs.test.ts | 6 +- .../hosted-worker/test/canonical-cbor.test.ts | 8 +- pkgs/id/hosted-worker/test/usage.test.ts | 2 +- pkgs/id/nix-common.nix | 20 +- pkgs/id/src/boards.rs | 119 +++---- pkgs/id/src/boards/records.rs | 1 - pkgs/id/src/currency/gateway.rs | 5 +- pkgs/id/src/lib.rs | 4 +- .../legacy-artifact-signatures.json | 2 +- pkgs/id/test-vectors/schema.json | 68 +++- pkgs/id/tests/transfer.rs | 3 +- pkgs/id/web/src/home.test.ts | 9 +- pkgs/id/web/src/tags-response.test.ts | 4 +- pkgs/id/web/src/tags.test.ts | 32 +- pkgs/id/web/src/world.ts | 4 +- 26 files changed, 553 insertions(+), 162 deletions(-) diff --git a/pkgs/id/WEB.md b/pkgs/id/WEB.md index 8df11d33b6..f62f16ff7d 100644 --- a/pkgs/id/WEB.md +++ b/pkgs/id/WEB.md @@ -236,31 +236,31 @@ Three DaisyUI terminal-inspired themes with `#000000` black backgrounds. Switch ## API Routes -| Route | Method | Description | -| --------------------- | ------ | ----------------------------------- | -| `/` | GET | File browser (main page) | -| `/peers` | GET | Discovered peers (auto-refreshes) | -| `/settings` | GET | Settings page | -| `/edit/{hash}` | GET | Editor/viewer for file by hash | -| `/file/{name}` | GET | Editor/viewer for file by name | -| `/blob/{hash}` | GET | Raw blob content with Content-Type | -| `/api/files` | GET | File list (HTML partial) | -| `/api/save` | POST | Save file content | -| `/api/new` | POST | Create new file | -| `/api/rename` | POST | Rename file (with optional archive) | -| `/api/copy` | POST | Copy file to new name | +| Route | Method | Description | +| --------------------- | ------ | --------------------------------------------------------- | +| `/` | GET | File browser (main page) | +| `/peers` | GET | Discovered peers (auto-refreshes) | +| `/settings` | GET | Settings page | +| `/edit/{hash}` | GET | Editor/viewer for file by hash | +| `/file/{name}` | GET | Editor/viewer for file by name | +| `/blob/{hash}` | GET | Raw blob content with Content-Type | +| `/api/files` | GET | File list (HTML partial) | +| `/api/save` | POST | Save file content | +| `/api/new` | POST | Create new file | +| `/api/rename` | POST | Rename file (with optional archive) | +| `/api/copy` | POST | Copy file to new name | | `/api/files/send` | POST | Send file to another server (server-side transfer, #5346) | -| `/api/download` | POST | Download file content | -| `/api/delete` | POST | Soft-delete file | +| `/api/download` | POST | Download file content | +| `/api/delete` | POST | Soft-delete file | | `/api/restore` | POST | Restore deleted file (404 if missing, 409 if not deleted) | -| `/api/hard-delete` | POST | Permanently delete file | -| `/api/tags` | GET | Get tags for a file | -| `/api/tags` | POST | Set a tag | -| `/api/tags` | DELETE | Delete a tag | -| `/api/tags/search` | GET | Search tags | -| `/ws/collab/{doc_id}` | WS | Collaboration WebSocket | -| `/ws/tags` | WS | Tag change broadcast | -| `/assets/*` | GET | Static assets | +| `/api/hard-delete` | POST | Permanently delete file | +| `/api/tags` | GET | Get tags for a file | +| `/api/tags` | POST | Set a tag | +| `/api/tags` | DELETE | Delete a tag | +| `/api/tags/search` | GET | Search tags | +| `/ws/collab/{doc_id}` | WS | Collaboration WebSocket | +| `/ws/tags` | WS | Tag change broadcast | +| `/assets/*` | GET | Static assets | ## Configuration diff --git a/pkgs/id/benches/world_bench.rs b/pkgs/id/benches/world_bench.rs index f325d8b57b..1cdc179567 100644 --- a/pkgs/id/benches/world_bench.rs +++ b/pkgs/id/benches/world_bench.rs @@ -915,8 +915,7 @@ fn write_results_jsonl(cells: &[MatrixCell], quick: bool) -> Result<()> { let git_sha = std::env::var("ID_BENCH_GIT_SHA") .or_else(|_| std::env::var("GITHUB_SHA")) .unwrap_or_else(|_| "unknown".to_owned()); - let toolchain = - std::env::var("ID_BENCH_TOOLCHAIN").unwrap_or_else(|_| "unknown".to_owned()); + let toolchain = std::env::var("ID_BENCH_TOOLCHAIN").unwrap_or_else(|_| "unknown".to_owned()); let build_profile = if cfg!(debug_assertions) { "debug" } else { diff --git a/pkgs/id/crates/id-cli/src/commands/put.rs b/pkgs/id/crates/id-cli/src/commands/put.rs index 86e9598c22..51cdb23bbb 100644 --- a/pkgs/id/crates/id-cli/src/commands/put.rs +++ b/pkgs/id/crates/id-cli/src/commands/put.rs @@ -89,7 +89,6 @@ use crate::{ parse_stdin_items, read_input, }; - /// Trim a name typed at the forgiving CLI surface before FileOps sees it. /// /// FileOps stores names verbatim and refuses padding (#4102 / design #4766 diff --git a/pkgs/id/crates/id-directory/src/directory_auth.rs b/pkgs/id/crates/id-directory/src/directory_auth.rs index 0c916fb09a..e5860655d5 100644 --- a/pkgs/id/crates/id-directory/src/directory_auth.rs +++ b/pkgs/id/crates/id-directory/src/directory_auth.rs @@ -845,12 +845,22 @@ mod tests { .is_err() ); assert!( - auth.check_code("user0@x.co", PurposeKind::SignIn, &resent, now() + CODE_RESEND_MS) - .is_ok() + auth.check_code( + "user0@x.co", + PurposeKind::SignIn, + &resent, + now() + CODE_RESEND_MS + ) + .is_ok() ); assert!( - auth.check_code("user0@x.co", PurposeKind::SignIn, &resent, now() + CODE_RESEND_MS) - .is_err() + auth.check_code( + "user0@x.co", + PurposeKind::SignIn, + &resent, + now() + CODE_RESEND_MS + ) + .is_err() ); } @@ -894,7 +904,10 @@ mod tests { ) .unwrap(); assert_eq!(auth.codes.len(), CODE_PENDING_PER_ACCOUNT + 1); - assert!(auth.check_code("other@x.co", PurposeKind::SignIn, &other, now()).is_ok()); + assert!( + auth.check_code("other@x.co", PurposeKind::SignIn, &other, now()) + .is_ok() + ); // A resend for one of the account's own pending addresses still // replaces at the per-account cap. (Checking the other account's // code above consumed it, so the map is back to the account's own diff --git a/pkgs/id/crates/id-native-shell/Cargo.toml b/pkgs/id/crates/id-native-shell/Cargo.toml index 26de64721b..dc90aebdff 100644 --- a/pkgs/id/crates/id-native-shell/Cargo.toml +++ b/pkgs/id/crates/id-native-shell/Cargo.toml @@ -39,7 +39,9 @@ tokio = { version = "1", features = ["full"] } # id-web tests do: id-worlds with the sandbox feature, plus the # in-memory blob store the fixture recorder expects. Dev-only: none of # this reaches the shipped shell or the default `id` build. -id-worlds = { path = "../id-worlds", default-features = false, features = ["sandbox"] } +id-worlds = { path = "../id-worlds", default-features = false, features = [ + "sandbox", +] } iroh-blobs = "0.103" [lints.rust] diff --git a/pkgs/id/crates/id-sync/Cargo.toml b/pkgs/id/crates/id-sync/Cargo.toml index 75c48690b5..5661c74b1a 100644 --- a/pkgs/id/crates/id-sync/Cargo.toml +++ b/pkgs/id/crates/id-sync/Cargo.toml @@ -57,7 +57,9 @@ p2panda-auth = { git = "https://github.com/p2panda/p2panda", rev = "da80c05b9526 "serde", ] } # The artifact and envelope network tests use id-core silent lookup helpers. -id-core = { path = "../id-core", default-features = false, features = ["test-utils"] } +id-core = { path = "../id-core", default-features = false, features = [ + "test-utils", +] } proptest = "1.12" tempfile = "3" tokio = { version = "1", features = ["test-util"] } diff --git a/pkgs/id/crates/id-sync/src/transfer.rs b/pkgs/id/crates/id-sync/src/transfer.rs index 66198b81e0..d319313f7a 100644 --- a/pkgs/id/crates/id-sync/src/transfer.rs +++ b/pkgs/id/crates/id-sync/src/transfer.rs @@ -42,9 +42,9 @@ use iroh::{EndpointAddr, endpoint::Endpoint}; use iroh_base::EndpointId; use iroh_blobs::{Hash, api::Store}; -use crate::protocol::META_ALPN; use crate::meta_client::push_and_name; use crate::meta_client::{expect_ok, request_over}; +use crate::protocol::META_ALPN; use crate::protocol::{MetaRequest, MetaResponse}; /// What a completed (or already-completed) transfer did. diff --git a/pkgs/id/crates/id-web/src/markdown/parse_helpers.rs b/pkgs/id/crates/id-web/src/markdown/parse_helpers.rs index 02e20c5fa9..472f5b7c59 100644 --- a/pkgs/id/crates/id-web/src/markdown/parse_helpers.rs +++ b/pkgs/id/crates/id-web/src/markdown/parse_helpers.rs @@ -1304,7 +1304,9 @@ fn code_span_closes_within_paragraph(bytes: &[u8], from: usize, n: usize) -> boo } b'\n' => { let mut m = k + 1; - while m < bytes.len() && (bytes[m] == b' ' || bytes[m] == b'\t' || bytes[m] == b'\r') { + while m < bytes.len() + && (bytes[m] == b' ' || bytes[m] == b'\t' || bytes[m] == b'\r') + { m += 1; } if m >= bytes.len() || bytes[m] == b'\n' { diff --git a/pkgs/id/examples/roc-import-policy/fixtures.json b/pkgs/id/examples/roc-import-policy/fixtures.json index bc5c06b8be..ab767ce9f1 100644 --- a/pkgs/id/examples/roc-import-policy/fixtures.json +++ b/pkgs/id/examples/roc-import-policy/fixtures.json @@ -1 +1,302 @@ -{"cases":[{"case":"pure-positive","discovered_used":[],"expected":{"outcome":"accepted"},"import":{"hash":"blake3:pure1","name":"pure-parser","source":"registry","url_bytes_verified":true,"version":"0.1.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"pure-parser\" version=\"0.1.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:pure1\"\n license \"MIT\"\n}\n"}],"matrix":"#5994 §4 pure positive control: a pure package declares no platform requirements and imports on any profile","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":[]},{"case":"standard-positive","discovered_used":["records.read"],"expected":{"outcome":"accepted"},"import":{"hash":"blake3:9f2","name":"greeter","source":"registry","url_bytes_verified":true,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n"}],"matrix":"#5994 §4 standard-dependent, covered: requirements on the platform and in the world requested set","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["records.read"]},{"case":"standard-negative-not-on-platform","discovered_used":[],"expected":{"failures":[{"excess":["RocCap","records.read"],"subreason":"not_on_platform"}],"outcome":"refused"},"import":{"hash":"blake3:9f2","name":"greeter","source":"registry","url_bytes_verified":true,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"RocCap\"\n requires \"records.read\"\n }\n}\n"}],"matrix":"#5994 §4 standard-dependent negative + #5956 §5 worked example: RocCap/records.read package against the reduced platform without them","platform":{"identity":"roc-world/platform-no-caps","surface":[]},"require_checked":false,"world_requested":["RocCap","records.read"]},{"case":"standard-negative-not-requested","discovered_used":[],"expected":{"failures":[{"excess":["chat.say"],"subreason":"not_requested"}],"outcome":"refused"},"import":{"hash":"blake3:9f2","name":"greeter","source":"registry","url_bytes_verified":true,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n requires \"chat.say\"\n }\n}\n"}],"matrix":"#5956 §3 check 2: the platform serves the requirements but the world never requested one of them; a library may not widen the world transitively","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["records.read"]},{"case":"transitive-negative-not-on-platform","discovered_used":[],"expected":{"failures":[{"excess":["chat.say"],"subreason":"not_on_platform"}],"outcome":"refused"},"import":{"hash":"blake3:9f2","name":"greeter","source":"registry","url_bytes_verified":true,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":["blake3:dep1"],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n"},{"depends_on":[],"kdl":"library \"chatter\" version=\"0.3.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:dep1\"\n license \"MIT\"\n platform {\n requires \"chat.say\"\n }\n}\n"}],"matrix":"#5956 §3 check 1 over the closure: the excess arrives through a dependency, not the imported library's own declarations","platform":{"identity":"roc-world/standard","surface":["records.read"]},"require_checked":false,"world_requested":["records.read","chat.say"]},{"case":"scratch-fs-negative","discovered_used":[],"expected":{"failures":[{"excess":["fs.read"],"subreason":"unknown_requirement"}],"outcome":"refused"},"import":{"hash":"blake3:fs1","name":"scratch-notes","source":"registry","url_bytes_verified":true,"version":"0.1.0","world":"chess-room"},"manifests":[{"depends_on":[],"record":{"build_mode":"compile-in","hash":"blake3:fs1","kind":"source-library","license":"MIT","name":"scratch-notes","requirements":[{"name":"fs.read","version_pin":null}],"version":"0.1.0"}}],"matrix":"#5994 §4 scratch-filesystem negative, specified now: fs.read names no entry in the current catalog (no file provider exists yet), so the compiling catalog refuses it as unknown_requirement; when the provider lands this oracle moves to not_on_platform against the standard-only surface","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["fs.read"]},{"case":"host-read-negative","discovered_used":[],"expected":{"failures":[{"excess":["fs.host_read"],"subreason":"unknown_requirement"}],"outcome":"refused"},"import":{"hash":"blake3:hr1","name":"host-reader","source":"registry","url_bytes_verified":true,"version":"0.1.0","world":"chess-room"},"manifests":[{"depends_on":[],"record":{"build_mode":"compile-in","hash":"blake3:hr1","kind":"source-library","license":"MIT","name":"host-reader","requirements":[{"name":"fs.host_read","version_pin":null}],"version":"0.1.0"}}],"matrix":"#5994 §4 host-read negative, specified now: fs.host_read names no entry in the current catalog; refused as unknown_requirement, never as an unbounded host path","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["fs.host_read"]},{"case":"net-negative","discovered_used":[],"expected":{"failures":[{"excess":["net.connect"],"subreason":"unknown_requirement"}],"outcome":"refused"},"import":{"hash":"blake3:net1","name":"pinger","source":"registry","url_bytes_verified":true,"version":"0.1.0","world":"chess-room"},"manifests":[{"depends_on":[],"record":{"build_mode":"compile-in","hash":"blake3:net1","kind":"source-library","license":"MIT","name":"pinger","requirements":[{"name":"net.connect","version_pin":null}],"version":"0.1.0"}}],"matrix":"#5994 §4 outbound-network negative, specified now: net.connect names no entry in the current catalog; refused as unknown_requirement, never as an unauthorized destination","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["net.connect"]},{"case":"url-declared-only-refused","discovered_used":[],"expected":{"failures":[{"excess":["records.read"],"subreason":"unverified_provenance"}],"outcome":"refused"},"import":{"hash":"blake3:9f2","name":"greeter","source":{"url":"https://example.invalid/greeter.roc"},"url_bytes_verified":false,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n"}],"matrix":"#5956 §4: a world whose policy requires checked requirements refuses a declared-only URL import, naming the state not a capability","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":true,"world_requested":["records.read"]},{"case":"url-declared-only-allowed","discovered_used":[],"expected":{"outcome":"accepted"},"import":{"hash":"blake3:9f2","name":"greeter","source":{"url":"https://example.invalid/greeter.roc"},"url_bytes_verified":false,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n"}],"matrix":"#5956 §4: without the checked-requirements policy, declared requirements participate as declared-not-checked and the import compiles","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["records.read"]},{"case":"declaration-mismatch","discovered_used":["records.read","time.now"],"expected":{"failures":[{"excess":["time.now"],"subreason":"declaration_mismatch"}],"outcome":"refused"},"import":{"hash":"blake3:9f2","name":"greeter","source":"registry","url_bytes_verified":true,"version":"1.0.0","world":"chess-room"},"manifests":[{"depends_on":[],"kdl":"library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n"}],"matrix":"#5956 §3 check 3 / §5 declaration_mismatch: the closure is discovered to use time.now, which no closure manifest declares","platform":{"identity":"roc-world/standard","surface_from":"standard_surface"},"require_checked":false,"world_requested":["records.read","time.now"]}],"catalog_version":"2026-11","standard_surface":["RocCap","records.read","chat.say","time.now","players","random.u64"]} \ No newline at end of file +{ + "cases": [ + { + "case": "pure-positive", + "discovered_used": [], + "expected": { "outcome": "accepted" }, + "import": { + "hash": "blake3:pure1", + "name": "pure-parser", + "source": "registry", + "url_bytes_verified": true, + "version": "0.1.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"pure-parser\" version=\"0.1.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:pure1\"\n license \"MIT\"\n}\n" + } + ], + "matrix": "#5994 §4 pure positive control: a pure package declares no platform requirements and imports on any profile", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": [] + }, + { + "case": "standard-positive", + "discovered_used": ["records.read"], + "expected": { "outcome": "accepted" }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": "registry", + "url_bytes_verified": true, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n" + } + ], + "matrix": "#5994 §4 standard-dependent, covered: requirements on the platform and in the world requested set", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["records.read"] + }, + { + "case": "standard-negative-not-on-platform", + "discovered_used": [], + "expected": { + "failures": [{ "excess": ["RocCap", "records.read"], "subreason": "not_on_platform" }], + "outcome": "refused" + }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": "registry", + "url_bytes_verified": true, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"RocCap\"\n requires \"records.read\"\n }\n}\n" + } + ], + "matrix": "#5994 §4 standard-dependent negative + #5956 §5 worked example: RocCap/records.read package against the reduced platform without them", + "platform": { "identity": "roc-world/platform-no-caps", "surface": [] }, + "require_checked": false, + "world_requested": ["RocCap", "records.read"] + }, + { + "case": "standard-negative-not-requested", + "discovered_used": [], + "expected": { "failures": [{ "excess": ["chat.say"], "subreason": "not_requested" }], "outcome": "refused" }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": "registry", + "url_bytes_verified": true, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n requires \"chat.say\"\n }\n}\n" + } + ], + "matrix": "#5956 §3 check 2: the platform serves the requirements but the world never requested one of them; a library may not widen the world transitively", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["records.read"] + }, + { + "case": "transitive-negative-not-on-platform", + "discovered_used": [], + "expected": { "failures": [{ "excess": ["chat.say"], "subreason": "not_on_platform" }], "outcome": "refused" }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": "registry", + "url_bytes_verified": true, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": ["blake3:dep1"], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n" + }, + { + "depends_on": [], + "kdl": "library \"chatter\" version=\"0.3.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:dep1\"\n license \"MIT\"\n platform {\n requires \"chat.say\"\n }\n}\n" + } + ], + "matrix": "#5956 §3 check 1 over the closure: the excess arrives through a dependency, not the imported library's own declarations", + "platform": { "identity": "roc-world/standard", "surface": ["records.read"] }, + "require_checked": false, + "world_requested": ["records.read", "chat.say"] + }, + { + "case": "scratch-fs-negative", + "discovered_used": [], + "expected": { "failures": [{ "excess": ["fs.read"], "subreason": "unknown_requirement" }], "outcome": "refused" }, + "import": { + "hash": "blake3:fs1", + "name": "scratch-notes", + "source": "registry", + "url_bytes_verified": true, + "version": "0.1.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "record": { + "build_mode": "compile-in", + "hash": "blake3:fs1", + "kind": "source-library", + "license": "MIT", + "name": "scratch-notes", + "requirements": [{ "name": "fs.read", "version_pin": null }], + "version": "0.1.0" + } + } + ], + "matrix": "#5994 §4 scratch-filesystem negative, specified now: fs.read names no entry in the current catalog (no file provider exists yet), so the compiling catalog refuses it as unknown_requirement; when the provider lands this oracle moves to not_on_platform against the standard-only surface", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["fs.read"] + }, + { + "case": "host-read-negative", + "discovered_used": [], + "expected": { + "failures": [{ "excess": ["fs.host_read"], "subreason": "unknown_requirement" }], + "outcome": "refused" + }, + "import": { + "hash": "blake3:hr1", + "name": "host-reader", + "source": "registry", + "url_bytes_verified": true, + "version": "0.1.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "record": { + "build_mode": "compile-in", + "hash": "blake3:hr1", + "kind": "source-library", + "license": "MIT", + "name": "host-reader", + "requirements": [{ "name": "fs.host_read", "version_pin": null }], + "version": "0.1.0" + } + } + ], + "matrix": "#5994 §4 host-read negative, specified now: fs.host_read names no entry in the current catalog; refused as unknown_requirement, never as an unbounded host path", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["fs.host_read"] + }, + { + "case": "net-negative", + "discovered_used": [], + "expected": { + "failures": [{ "excess": ["net.connect"], "subreason": "unknown_requirement" }], + "outcome": "refused" + }, + "import": { + "hash": "blake3:net1", + "name": "pinger", + "source": "registry", + "url_bytes_verified": true, + "version": "0.1.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "record": { + "build_mode": "compile-in", + "hash": "blake3:net1", + "kind": "source-library", + "license": "MIT", + "name": "pinger", + "requirements": [{ "name": "net.connect", "version_pin": null }], + "version": "0.1.0" + } + } + ], + "matrix": "#5994 §4 outbound-network negative, specified now: net.connect names no entry in the current catalog; refused as unknown_requirement, never as an unauthorized destination", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["net.connect"] + }, + { + "case": "url-declared-only-refused", + "discovered_used": [], + "expected": { + "failures": [{ "excess": ["records.read"], "subreason": "unverified_provenance" }], + "outcome": "refused" + }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": { "url": "https://example.invalid/greeter.roc" }, + "url_bytes_verified": false, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n" + } + ], + "matrix": "#5956 §4: a world whose policy requires checked requirements refuses a declared-only URL import, naming the state not a capability", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": true, + "world_requested": ["records.read"] + }, + { + "case": "url-declared-only-allowed", + "discovered_used": [], + "expected": { "outcome": "accepted" }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": { "url": "https://example.invalid/greeter.roc" }, + "url_bytes_verified": false, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n" + } + ], + "matrix": "#5956 §4: without the checked-requirements policy, declared requirements participate as declared-not-checked and the import compiles", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["records.read"] + }, + { + "case": "declaration-mismatch", + "discovered_used": ["records.read", "time.now"], + "expected": { + "failures": [{ "excess": ["time.now"], "subreason": "declaration_mismatch" }], + "outcome": "refused" + }, + "import": { + "hash": "blake3:9f2", + "name": "greeter", + "source": "registry", + "url_bytes_verified": true, + "version": "1.0.0", + "world": "chess-room" + }, + "manifests": [ + { + "depends_on": [], + "kdl": "library \"greeter\" version=\"1.0.0\" {\n kind \"source-library\"\n build-mode \"compile-in\"\n hash \"blake3:9f2\"\n license \"MIT\"\n platform {\n requires \"records.read\"\n }\n}\n" + } + ], + "matrix": "#5956 §3 check 3 / §5 declaration_mismatch: the closure is discovered to use time.now, which no closure manifest declares", + "platform": { "identity": "roc-world/standard", "surface_from": "standard_surface" }, + "require_checked": false, + "world_requested": ["records.read", "time.now"] + } + ], + "catalog_version": "2026-11", + "standard_surface": ["RocCap", "records.read", "chat.say", "time.now", "players", "random.u64"] +} diff --git a/pkgs/id/hosted-worker/src/routing.ts b/pkgs/id/hosted-worker/src/routing.ts index a43a4a413d..40e85ccf6c 100644 --- a/pkgs/id/hosted-worker/src/routing.ts +++ b/pkgs/id/hosted-worker/src/routing.ts @@ -61,10 +61,7 @@ export interface R2BucketLike { * to the package's single local binding (BLOBS); per-jurisdiction * production buckets plug in at this one point when the #3403 * provisioning gate lands. A missing binding fails closed. */ -export function blobsBindingFor( - env: { BLOBS?: R2BucketLike }, - jurisdiction: Jurisdiction, -): R2BucketLike { +export function blobsBindingFor(env: { BLOBS?: R2BucketLike }, jurisdiction: Jurisdiction): R2BucketLike { void jurisdiction; if (!env.BLOBS) { throw new FailClosed(503, "blobs_unavailable", "no blob bucket binding is configured; failing closed"); diff --git a/pkgs/id/hosted-worker/src/user-do.ts b/pkgs/id/hosted-worker/src/user-do.ts index 402a4e9455..69cb858c56 100644 --- a/pkgs/id/hosted-worker/src/user-do.ts +++ b/pkgs/id/hosted-worker/src/user-do.ts @@ -22,7 +22,14 @@ // equals the routed identity — a mismatch fails closed. // Any guard failure returns before side effects. -import { FailClosed, blobsBindingFor, parseBindingId, parseJurisdiction, type Jurisdiction, type R2BucketLike } from "./routing.ts"; +import { + FailClosed, + blobsBindingFor, + parseBindingId, + parseJurisdiction, + type Jurisdiction, + type R2BucketLike, +} from "./routing.ts"; export const SCHEMA_VERSION = 2; @@ -91,7 +98,11 @@ export class UserDO { if (raw === undefined || raw === "") return null; const n = Number(raw); if (!Number.isInteger(n) || n < 0) { - throw new FailClosed(500, "ceiling_misconfigured", "USER_CEILING_BYTES is not a non-negative integer; writes fail closed"); + throw new FailClosed( + 500, + "ceiling_misconfigured", + "USER_CEILING_BYTES is not a non-negative integer; writes fail closed", + ); } return n; } @@ -207,7 +218,11 @@ export class UserDO { jurisdiction, usage: this.usage(), kv: Object.fromEntries(kvRows.map((r) => [String(r.key), String(r.value)])), - blobs: blobRows.map((r) => ({ hash: String(r.hash), size: Number(r.size), created_at: String(r.created_at) })), + blobs: blobRows.map((r) => ({ + hash: String(r.hash), + size: Number(r.size), + created_at: String(r.created_at), + })), }); } if (url.pathname === "/v1/state" && req.method === "GET") { @@ -242,9 +257,7 @@ export class UserDO { } if (blobHashMatch && req.method === "GET") { const hash = blobHashMatch[1]; - const rows = this.state.storage.sql - .exec("SELECT size FROM blobs WHERE hash = ?", hash) - .toArray(); + const rows = this.state.storage.sql.exec("SELECT size FROM blobs WHERE hash = ?", hash).toArray(); if (rows.length === 0) return json({ error: "not_found" }, 404); const bucket = blobsBindingFor(this.env, jurisdiction as Jurisdiction); const obj = await bucket.get(hash); @@ -260,9 +273,7 @@ export class UserDO { } if (blobHashMatch && req.method === "DELETE") { const hash = blobHashMatch[1]; - const rows = this.state.storage.sql - .exec("SELECT hash FROM blobs WHERE hash = ?", hash) - .toArray(); + const rows = this.state.storage.sql.exec("SELECT hash FROM blobs WHERE hash = ?", hash).toArray(); if (rows.length === 0) return json({ error: "not_found" }, 404); this.state.storage.sql.exec("DELETE FROM blobs WHERE hash = ?", hash); // The reference is gone, so this user can no longer reach @@ -277,7 +288,9 @@ export class UserDO { const kvMatch = url.pathname.match(/^\/v1\/kv\/([A-Za-z0-9._-]{1,128})$/); if (kvMatch && req.method === "PUT") { const value = await req.text(); - const prior = this.state.storage.sql.exec("SELECT LENGTH(value) AS n FROM kv WHERE key = ?", kvMatch[1]).toArray(); + const prior = this.state.storage.sql + .exec("SELECT LENGTH(value) AS n FROM kv WHERE key = ?", kvMatch[1]) + .toArray(); const priorBytes = prior.length === 0 ? 0 : Number(prior[0].n); this.assertWritable(new TextEncoder().encode(value).byteLength - priorBytes); this.state.storage.sql.exec( diff --git a/pkgs/id/hosted-worker/test/blobs.test.ts b/pkgs/id/hosted-worker/test/blobs.test.ts index 6b87854693..a6ce7682c9 100644 --- a/pkgs/id/hosted-worker/test/blobs.test.ts +++ b/pkgs/id/hosted-worker/test/blobs.test.ts @@ -60,7 +60,7 @@ function makeDO(name: string, bucket: ReturnType) { const state = { id: { name }, storage: { sql: fakeSql() }, - blockConcurrencyWhile: async (fn: () => Promise): Promise => fn(), + blockConcurrencyWhile: async (fn: () => Promise): Promise => fn(), }; return new UserDO(state as never, { BLOBS: bucket } as never); } @@ -121,7 +121,9 @@ test("delete removes only the caller's reference; shared bytes survive", async ( const doA = makeDO(A, bucket); const doB = makeDO(B, bucket); const bytes = new TextEncoder().encode("delete me not"); - const { hash } = (await (await doA.fetch(routed("/v1/blobs", A, { method: "PUT", body: bytes }))).json()) as { hash: string }; + const { hash } = (await (await doA.fetch(routed("/v1/blobs", A, { method: "PUT", body: bytes }))).json()) as { + hash: string; + }; await doB.fetch(routed("/v1/blobs", B, { method: "PUT", body: bytes })); const del = await doA.fetch(routed("/v1/blobs/" + hash, A, { method: "DELETE" })); diff --git a/pkgs/id/hosted-worker/test/canonical-cbor.test.ts b/pkgs/id/hosted-worker/test/canonical-cbor.test.ts index 815714b90d..d81ac2d4a7 100644 --- a/pkgs/id/hosted-worker/test/canonical-cbor.test.ts +++ b/pkgs/id/hosted-worker/test/canonical-cbor.test.ts @@ -1,13 +1,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import { - CborError, - decodeCanonical, - encodeCanonical, - validateRecord, - type CborValue, -} from "../src/canonical-cbor.ts"; +import { CborError, decodeCanonical, encodeCanonical, validateRecord, type CborValue } from "../src/canonical-cbor.ts"; // The golden table is shared with the Rust suite // (crates/id-core/tests/canonical_cbor_vectors.rs): same logical diff --git a/pkgs/id/hosted-worker/test/usage.test.ts b/pkgs/id/hosted-worker/test/usage.test.ts index fdac4d7af9..f18f21991c 100644 --- a/pkgs/id/hosted-worker/test/usage.test.ts +++ b/pkgs/id/hosted-worker/test/usage.test.ts @@ -59,7 +59,7 @@ function makeDO(env: Record = {}) { const state = { id: { name: A }, storage: { sql: fakeSql() }, - blockConcurrencyWhile: async (fn: () => Promise): Promise => fn(), + blockConcurrencyWhile: async (fn: () => Promise): Promise => fn(), }; return { doA: new UserDO(state as never, { BLOBS: bucket, ...env } as never), bucket }; } diff --git a/pkgs/id/nix-common.nix b/pkgs/id/nix-common.nix index b8fbf7dc78..385561f861 100644 --- a/pkgs/id/nix-common.nix +++ b/pkgs/id/nix-common.nix @@ -154,15 +154,17 @@ in # id-native-shell runtime libraries (design #788 step 2): winit / # wgpu dlopen wayland, xkbcommon, X11 and Vulkan at runtime. - export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ - pkgs.wayland - pkgs.libxkbcommon - pkgs.xorg.libX11 - pkgs.xorg.libXcursor - pkgs.xorg.libXrandr - pkgs.xorg.libXi - pkgs.vulkan-loader - ]}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + export LD_LIBRARY_PATH="${ + pkgs.lib.makeLibraryPath [ + pkgs.wayland + pkgs.libxkbcommon + pkgs.xorg.libX11 + pkgs.xorg.libXcursor + pkgs.xorg.libXrandr + pkgs.xorg.libXi + pkgs.vulkan-loader + ] + }''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" # Playwright E2E testing: use Nix-provided browsers export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 diff --git a/pkgs/id/src/boards.rs b/pkgs/id/src/boards.rs index 870c945766..0cc6c3339e 100644 --- a/pkgs/id/src/boards.rs +++ b/pkgs/id/src/boards.rs @@ -598,7 +598,6 @@ impl BoardGraph { .collect() } - fn validate_links(&self, signed: &SignedBoardObject) -> Result<()> { let author = signed.artifact.author.as_str(); match &signed.object { @@ -6975,9 +6974,11 @@ mod tests { assert_eq!(embeds[0].0, post_hash); assert_eq!(embeds[0].1, ¬e_ref); assert_eq!(graph.note_backlinks(¬e_object), vec![post_hash.clone()]); - assert!(graph - .note_backlinks(&ArtifactHash::new("d".repeat(64)).unwrap()) - .is_empty()); + assert!( + graph + .note_backlinks(&ArtifactHash::new("d".repeat(64)).unwrap()) + .is_empty() + ); assert_ne!(plain_hash, post_hash); // The signed body carries the reference fields only: pinned @@ -6989,7 +6990,10 @@ mod tests { }; let stored_ref = stored_post.note_ref.as_ref().unwrap(); assert_eq!(stored_ref.pinned_version.as_str(), "b".repeat(64).as_str()); - assert_eq!(stored_ref.pinned_content_hash.as_str(), "c".repeat(64).as_str()); + assert_eq!( + stored_ref.pinned_content_hash.as_str(), + "c".repeat(64).as_str() + ); assert_eq!(stored_post.body, "sharing a note"); } @@ -7006,27 +7010,31 @@ mod tests { // Signed by the creator but naming someone else as sharer. let mut foreign = sample_note_ref(&creator); foreign.sharer = hex_encode(&other.verifying_key().to_bytes()); - assert!(graph - .insert(post_with_note_ref( - &creator, - root_hash.clone(), - thread_hash.clone(), - foreign, - "misattributed share", - )) - .is_err()); + assert!( + graph + .insert(post_with_note_ref( + &creator, + root_hash.clone(), + thread_hash.clone(), + foreign, + "misattributed share", + )) + .is_err() + ); // Signed by the other key while naming the creator as sharer: // the signature must be the sharer's either way. - assert!(graph - .insert(post_with_note_ref( - &other, - root_hash, - thread_hash, - sample_note_ref(&creator), - "forged share", - )) - .is_err()); + assert!( + graph + .insert(post_with_note_ref( + &other, + root_hash, + thread_hash, + sample_note_ref(&creator), + "forged share", + )) + .is_err() + ); } #[test] @@ -7037,39 +7045,43 @@ mod tests { let mut bad_sharer = sample_note_ref(&creator); bad_sharer.sharer = "not-a-public-key".to_owned(); - assert!(SignedBoardObject::sign( - &creator, - 1, - "", - BoardObject::Post(Post { - board: board_hash.clone(), - thread: thread_hash.clone(), - parent_post: None, - body: "x".to_owned(), - attachments: Vec::new(), - embed_ref: None, - note_ref: Some(bad_sharer), - }), - ) - .is_err()); + assert!( + SignedBoardObject::sign( + &creator, + 1, + "", + BoardObject::Post(Post { + board: board_hash.clone(), + thread: thread_hash.clone(), + parent_post: None, + body: "x".to_owned(), + attachments: Vec::new(), + embed_ref: None, + note_ref: Some(bad_sharer), + }), + ) + .is_err() + ); let mut no_home = sample_note_ref(&creator); no_home.home_server = String::new(); - assert!(SignedBoardObject::sign( - &creator, - 1, - "", - BoardObject::Post(Post { - board: board_hash, - thread: thread_hash, - parent_post: None, - body: "x".to_owned(), - attachments: Vec::new(), - embed_ref: None, - note_ref: Some(no_home), - }), - ) - .is_err()); + assert!( + SignedBoardObject::sign( + &creator, + 1, + "", + BoardObject::Post(Post { + board: board_hash, + thread: thread_hash, + parent_post: None, + body: "x".to_owned(), + attachments: Vec::new(), + embed_ref: None, + note_ref: Some(no_home), + }), + ) + .is_err() + ); } #[test] @@ -7090,5 +7102,4 @@ mod tests { let decoded: BoardObject = serde_json::from_value(value).unwrap(); assert_eq!(decoded, object); } - } diff --git a/pkgs/id/src/boards/records.rs b/pkgs/id/src/boards/records.rs index a2acc723a7..7c33e7ae6b 100644 --- a/pkgs/id/src/boards/records.rs +++ b/pkgs/id/src/boards/records.rs @@ -86,7 +86,6 @@ pub struct NoteRef { pub sharer: String, } - /// Immutable post or post revision. #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(deny_unknown_fields)] diff --git a/pkgs/id/src/currency/gateway.rs b/pkgs/id/src/currency/gateway.rs index dbe2ec9901..c862c9888b 100644 --- a/pkgs/id/src/currency/gateway.rs +++ b/pkgs/id/src/currency/gateway.rs @@ -876,7 +876,10 @@ mod tests { let over_long = "a".repeat(129); for nonce in ["", &over_long, "bad nonce"] { assert!( - matches!(sign_request(&client, &req, 10_000, nonce), Err(GatewayError::Envelope)), + matches!( + sign_request(&client, &req, 10_000, nonce), + Err(GatewayError::Envelope) + ), "nonce {nonce:?} must map to GatewayError::Envelope" ); } diff --git a/pkgs/id/src/lib.rs b/pkgs/id/src/lib.rs index 003d584001..ba7c34f7b7 100644 --- a/pkgs/id/src/lib.rs +++ b/pkgs/id/src/lib.rs @@ -357,8 +357,8 @@ pub use id_cli::commands::{ cmd_get_one_remote, cmd_gethash, cmd_id, cmd_list, cmd_list_remote, cmd_migrate_tags, cmd_peek, cmd_peers, cmd_put_hash, cmd_put_local_file, cmd_put_local_stdin, cmd_put_multi, cmd_put_one, cmd_put_one_remote, cmd_search, cmd_send, cmd_serve, cmd_show, cmd_tag, - create_local_client_endpoint, - create_serve_lock, get_serve_info, is_process_alive, remove_serve_lock, + create_local_client_endpoint, create_serve_lock, get_serve_info, is_process_alive, + remove_serve_lock, }; pub use id_cli::helpers::{ download_output_path, parse_get_spec, parse_put_spec, print_match_cli, print_match_repl, diff --git a/pkgs/id/test-vectors/legacy-artifact-signatures.json b/pkgs/id/test-vectors/legacy-artifact-signatures.json index 8ed998774f..da8fa0e324 100644 --- a/pkgs/id/test-vectors/legacy-artifact-signatures.json +++ b/pkgs/id/test-vectors/legacy-artifact-signatures.json @@ -118,4 +118,4 @@ "envelope_id_sha256_hex": "c661ef2de9f6e5936ad2ea0d9045114aa7aa486cfbf2b3033c3d3a0b979a53f3" } } -} \ No newline at end of file +} diff --git a/pkgs/id/test-vectors/schema.json b/pkgs/id/test-vectors/schema.json index 339c7e2e9f..19bec34974 100644 --- a/pkgs/id/test-vectors/schema.json +++ b/pkgs/id/test-vectors/schema.json @@ -1 +1,67 @@ -{"$defs":{"case":{"additionalProperties":false,"properties":{"expect":{"$ref":"#/$defs/expectation"},"name":{"minLength":1,"type":"string"},"required_capabilities":{"items":{"minLength":1,"type":"string"},"type":"array","uniqueItems":true},"steps":{"items":{"$ref":"#/$defs/step"},"minItems":1,"type":"array"}},"required":["name","required_capabilities","steps","expect"],"type":"object"},"expectation":{"additionalProperties":false,"properties":{"appended_records":{"minimum":0,"type":"integer"},"final_offsets":{"items":{"minimum":0,"type":"integer"},"type":"array"},"negotiation":{"enum":["granted","unsupported_capability","version_mismatch"],"type":"string"},"redelivery":{"type":"boolean"}},"type":"object"},"step":{"additionalProperties":false,"properties":{"consumer":{"type":"string"},"idempotency_key":{"type":["string","null"]},"max":{"minimum":0,"type":"integer"},"offset":{"minimum":0,"type":"integer"},"op":{"enum":["negotiate","append","read","ack"],"type":"string"},"operation_id":{"type":"string"},"payload_utf8":{"type":"string"}},"required":["op"],"type":"object"}},"$id":"https://developing-today.github.io/code/id/test-vectors.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"description":"Shared test-vector files for port-contract conformance (slice 9110-02, #10160). Every adapter family runs the same vectors; a vector records the port, the capabilities the case requires, an ordered step trace, and the expected outcomes, so duplicate/retry/redelivery behavior is checked identically across adapters.","properties":{"cases":{"items":{"$ref":"#/$defs/case"},"minItems":1,"type":"array"},"contract_version":{"minimum":1,"type":"integer"},"port_kind":{"enum":["record_store","blob_store","event_log","world_store","object_bucket","message_stream","request_transport"],"type":"string"},"schema_version":{"const":1,"type":"integer"}},"required":["schema_version","port_kind","contract_version","cases"],"title":"ID/Atlas shared conformance test vectors","type":"object"} \ No newline at end of file +{ + "$defs": { + "case": { + "additionalProperties": false, + "properties": { + "expect": { "$ref": "#/$defs/expectation" }, + "name": { "minLength": 1, "type": "string" }, + "required_capabilities": { + "items": { "minLength": 1, "type": "string" }, + "type": "array", + "uniqueItems": true + }, + "steps": { "items": { "$ref": "#/$defs/step" }, "minItems": 1, "type": "array" } + }, + "required": ["name", "required_capabilities", "steps", "expect"], + "type": "object" + }, + "expectation": { + "additionalProperties": false, + "properties": { + "appended_records": { "minimum": 0, "type": "integer" }, + "final_offsets": { "items": { "minimum": 0, "type": "integer" }, "type": "array" }, + "negotiation": { "enum": ["granted", "unsupported_capability", "version_mismatch"], "type": "string" }, + "redelivery": { "type": "boolean" } + }, + "type": "object" + }, + "step": { + "additionalProperties": false, + "properties": { + "consumer": { "type": "string" }, + "idempotency_key": { "type": ["string", "null"] }, + "max": { "minimum": 0, "type": "integer" }, + "offset": { "minimum": 0, "type": "integer" }, + "op": { "enum": ["negotiate", "append", "read", "ack"], "type": "string" }, + "operation_id": { "type": "string" }, + "payload_utf8": { "type": "string" } + }, + "required": ["op"], + "type": "object" + } + }, + "$id": "https://developing-today.github.io/code/id/test-vectors.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "description": "Shared test-vector files for port-contract conformance (slice 9110-02, #10160). Every adapter family runs the same vectors; a vector records the port, the capabilities the case requires, an ordered step trace, and the expected outcomes, so duplicate/retry/redelivery behavior is checked identically across adapters.", + "properties": { + "cases": { "items": { "$ref": "#/$defs/case" }, "minItems": 1, "type": "array" }, + "contract_version": { "minimum": 1, "type": "integer" }, + "port_kind": { + "enum": [ + "record_store", + "blob_store", + "event_log", + "world_store", + "object_bucket", + "message_stream", + "request_transport" + ], + "type": "string" + }, + "schema_version": { "const": 1, "type": "integer" } + }, + "required": ["schema_version", "port_kind", "contract_version", "cases"], + "title": "ID/Atlas shared conformance test vectors", + "type": "object" +} diff --git a/pkgs/id/tests/transfer.rs b/pkgs/id/tests/transfer.rs index 960bc87a29..1cb23b2115 100644 --- a/pkgs/id/tests/transfer.rs +++ b/pkgs/id/tests/transfer.rs @@ -12,7 +12,6 @@ use id::transfer::send_file; use id::{MetaRequest, MetaResponse}; use iroh_blobs::Hash; - /// Put `data` on `node` under `name`; returns the content hash. async fn put_named(node: &LocalNode, name: &str, data: &[u8]) -> Hash { let (hash, _guard) = add_raw(&node.blobs(), data.to_vec()).await.unwrap(); @@ -199,4 +198,4 @@ async fn destination_that_does_not_allow_the_source_denies_the_send() { router.shutdown().await.unwrap(); source.shutdown().await.unwrap(); dest.shutdown().await.unwrap(); -} \ No newline at end of file +} diff --git a/pkgs/id/web/src/home.test.ts b/pkgs/id/web/src/home.test.ts index 8e1e9c7cdf..a44719fbc7 100644 --- a/pkgs/id/web/src/home.test.ts +++ b/pkgs/id/web/src/home.test.ts @@ -113,18 +113,13 @@ describe("home feed validation (#7811)", () => { `; const lists = Array.from(document.querySelectorAll("[data-home-app] ol")); const previousMarkup = lists.map((list) => list.innerHTML); - vi.stubGlobal( - "fetch", - vi.fn().mockResolvedValue({ ok: true, json: async () => malformedFeed }), - ); + vi.stubGlobal("fetch", vi.fn().mockResolvedValue({ ok: true, json: async () => malformedFeed })); initHome(); await new Promise((resolve) => setTimeout(resolve, 0)); expect(lists.map((list) => list.innerHTML)).toEqual(previousMarkup); - expect(document.querySelector("[data-home-updated]")?.textContent).toBe( - "Feed is temporarily unavailable.", - ); + expect(document.querySelector("[data-home-updated]")?.textContent).toBe("Feed is temporarily unavailable."); } } finally { if (visibility) Object.defineProperty(document, "visibilityState", visibility); diff --git a/pkgs/id/web/src/tags-response.test.ts b/pkgs/id/web/src/tags-response.test.ts index ca1e21889d..5262340306 100644 --- a/pkgs/id/web/src/tags-response.test.ts +++ b/pkgs/id/web/src/tags-response.test.ts @@ -23,9 +23,7 @@ describe("parseTagsResponse control shapes", () => { }); it("parses the flat array form", () => { - expect(parseTagsResponse([{ key: "project", value: "alpha" }])).toEqual([ - { key: "project", value: "alpha" }, - ]); + expect(parseTagsResponse([{ key: "project", value: "alpha" }])).toEqual([{ key: "project", value: "alpha" }]); }); it("parses an empty tag list as an empty array, not a failure", () => { diff --git a/pkgs/id/web/src/tags.test.ts b/pkgs/id/web/src/tags.test.ts index 779b70aa4a..24dce1aad8 100644 --- a/pkgs/id/web/src/tags.test.ts +++ b/pkgs/id/web/src/tags.test.ts @@ -78,10 +78,7 @@ describe("loadFileTags response validation (#7841)", () => { window.idApp.renderEditorTags([{ key: "stale", value: "old" }]); expect(document.querySelectorAll(".tag-pill-removable").length).toBe(1); - vi.stubGlobal( - "fetch", - async () => ({ ok: true, status: 200, json: async () => ({}) }), - ); + vi.stubGlobal("fetch", async () => ({ ok: true, status: 200, json: async () => ({}) })); try { await window.idApp.loadFileTags("other.md"); } finally { @@ -94,29 +91,24 @@ describe("loadFileTags response validation (#7841)", () => { it("renders the object control shape and filters system tags", async () => { await setup(); - vi.stubGlobal( - "fetch", - async () => ({ - ok: true, - status: 200, - json: async () => ({ - tags: [ - { key: "project", value: "alpha" }, - { key: "created", value: "2026-01-01" }, - { key: "plain", value: null }, - ], - }), + vi.stubGlobal("fetch", async () => ({ + ok: true, + status: 200, + json: async () => ({ + tags: [ + { key: "project", value: "alpha" }, + { key: "created", value: "2026-01-01" }, + { key: "plain", value: null }, + ], }), - ); + })); try { await window.idApp.loadFileTags("test.md"); } finally { vi.unstubAllGlobals(); } - const pills = [...document.querySelectorAll(".tag-pill-removable")].map((p) => - p.textContent?.replace("×", ""), - ); + const pills = [...document.querySelectorAll(".tag-pill-removable")].map((p) => p.textContent?.replace("×", "")); expect(pills).toEqual(["project: alpha", "plain"]); }); }); diff --git a/pkgs/id/web/src/world.ts b/pkgs/id/web/src/world.ts index 06a56e536b..0c4556706e 100644 --- a/pkgs/id/web/src/world.ts +++ b/pkgs/id/web/src/world.ts @@ -172,7 +172,9 @@ function initWorld(): void { Array.isArray(value.participants) && value.participants.every( (participant) => - isRecord(participant) && isSafeNonNegativeInteger(participant.id) && typeof participant.display_name === "string", + isRecord(participant) && + isSafeNonNegativeInteger(participant.id) && + typeof participant.display_name === "string", ); const isWorldEvent = (value: unknown): value is NonNullable => { if ( From d5f5a47c97948e00623e5199c1fcc5fa632ab373 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Sun, 15 Nov 2026 13:53:19 -0600 Subject: [PATCH 2/2] fix(id): add missing dht testnet dev dependency Fixes #8904 --- pkgs/id/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/id/Cargo.toml b/pkgs/id/Cargo.toml index 643dbe7e58..bc3bbdcf22 100644 --- a/pkgs/id/Cargo.toml +++ b/pkgs/id/Cargo.toml @@ -224,6 +224,8 @@ iroh = { version = "1", features = ["test-utils"] } toml = "1" # Local mainline DHT testnet for tests/dht_testnet.rs (P7.3). Dev only; already in the lock via the `dht` feature. n0-mainline = "0.7" +# Mainline DHT address lookup builder for tests/dht_testnet.rs (P7.3). Matches id-sync optional dep. +iroh-mainline-address-lookup = "0.6" # XSalsa20-Poly1305 for the Keybase V2 vector's pkey box (P6.1 known-answer test). Dev only; not in the lock before P6.1. crypto_secretbox = "0.1" # Reads the vector's msgpack byte strings (P6.1 known-answer test). Dev only; already in the lock.