From 5b395f50b9a730c3b73c898f41bbf177a0d92bb4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 19 Apr 2024 02:22:52 +0300 Subject: [PATCH] Additional relation support: * derivation * agent attribution Signed-off-by: Ryan --- Cargo.lock | 368 +++++++------ crates/api/src/chronicle_graphql/activity.rs | 14 +- crates/api/src/chronicle_graphql/agent.rs | 10 +- .../src/chronicle_graphql/authorization.rs | 16 +- crates/api/src/chronicle_graphql/entity.rs | 14 +- crates/api/src/chronicle_graphql/mod.rs | 105 ++-- crates/api/src/chronicle_graphql/mutation.rs | 52 +- crates/api/src/chronicle_graphql/query.rs | 32 +- crates/api/src/lib.rs | 3 +- crates/chronicle-arrow/src/lib.rs | 516 +++++++++++++++--- crates/chronicle-arrow/src/meta.rs | 35 +- .../src/operations/activity.rs | 123 ++++- .../chronicle-arrow/src/operations/agent.rs | 6 +- .../chronicle-arrow/src/operations/entity.rs | 12 +- crates/chronicle-arrow/src/operations/mod.rs | 19 +- crates/chronicle-arrow/src/peekablestream.rs | 44 -- crates/chronicle-arrow/src/query/activity.rs | 341 +++++++++--- crates/chronicle-arrow/src/query/agent.rs | 59 +- crates/chronicle-arrow/src/query/entity.rs | 8 +- crates/chronicle-arrow/src/query/mod.rs | 7 - crates/chronicle-domain-test/src/test.rs | 50 +- crates/chronicle-persistence/src/lib.rs | 45 +- crates/chronicle-persistence/src/query.rs | 6 +- crates/chronicle-synth/src/domain.rs | 2 +- .../src/api_test.rs | 375 +++++-------- .../src/cli_test.rs | 285 ++++------ .../src/substitutes/mod.rs | 6 +- .../src/substitutes/stubstrate.rs | 10 +- crates/chronicle/src/bootstrap/mod.rs | 39 +- crates/common/src/attributes.rs | 18 +- crates/common/src/opa/core.rs | 2 +- .../src/prov/model/json_ld/from_json_ld.rs | 261 ++++----- crates/common/src/prov/model/mod.rs | 14 + crates/common/src/prov/operations.rs | 2 + crates/opactl/src/test/mod.rs | 205 ++++--- 35 files changed, 1849 insertions(+), 1255 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8bf3efe2..72b22471 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -243,7 +243,7 @@ dependencies = [ "metrics-exporter-prometheus", "opa", "opentelemetry 0.22.0", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "poem", "protocol-substrate", "protocol-substrate-chronicle", @@ -859,7 +859,7 @@ dependencies = [ "proc-macro2", "quote", "strum 0.26.2", - "syn 2.0.59", + "syn 2.0.60", "thiserror", ] @@ -917,7 +917,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 0.38.32", + "rustix 0.38.34", "slab", "tracing", "windows-sys 0.52.0", @@ -956,9 +956,9 @@ dependencies = [ [[package]] name = "async-process" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad07b3443bfa10dcddf86a452ec48949e8e7fedf7392d82de3969fda99e90ed" +checksum = "a53fc6301894e04a92cb2584fedde80cb25ba8e02d9dc39d4a87d036e22f397d" dependencies = [ "async-channel 2.2.1", "async-io", @@ -969,27 +969,27 @@ dependencies = [ "cfg-if", "event-listener 5.3.0", "futures-lite", - "rustix 0.38.32", + "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] [[package]] name = "async-signal" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" +checksum = "afe66191c335039c7bb78f99dc7520b0cbb166b3a1cb33a03f53d8a1c6f2afda" dependencies = [ "async-io", - "async-lock 2.8.0", + "async-lock 3.3.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.32", + "rustix 0.38.34", "signal-hook-registry", "slab", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1022,7 +1022,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1039,7 +1039,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1234,7 +1234,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1493,9 +1493,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytecount" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" +checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce" [[package]] name = "bytemuck" @@ -1514,7 +1514,7 @@ checksum = "4da9a32f3fed317401fa3c862968128267c3106685286e15d5aaa3d7389c2f60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -1637,12 +1637,13 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "d32a725bc159af97c3e629873bb9f88fb8cf8a4867175f76dc987815ea07c83b" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -2146,7 +2147,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2791,7 +2792,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2824,7 +2825,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2841,7 +2842,7 @@ checksum = "ad08a837629ad949b73d032c637653d069e909cffe4ee7870b02301939ce39cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2913,7 +2914,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.10.0", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -2946,7 +2947,7 @@ checksum = "a668eda54683121533a393014d8692171709ff57a7d61f187b6e782719f8933f" dependencies = [ "darling_core 0.20.8", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3055,7 +3056,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3104,9 +3105,9 @@ dependencies = [ [[package]] name = "diesel" -version = "2.1.5" +version = "2.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fc05c17098f21b89bc7d98fe1dd3cce2c11c2ad8e145f2a44fe08ed28eb559" +checksum = "ff236accb9a5069572099f0b350a92e9560e8e63a9b8d546162f4a5e03026bb2" dependencies = [ "bitflags 2.5.0", "byteorder", @@ -3120,14 +3121,14 @@ dependencies = [ [[package]] name = "diesel_derives" -version = "2.1.3" +version = "2.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d02eecb814ae714ffe61ddc2db2dd03e6c49a42e269b5001355500d431cce0c" +checksum = "14701062d6bed917b5c7103bdffaee1e4609279e240488ad24e7bd979ca6866c" dependencies = [ "diesel_table_macro_syntax", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3147,7 +3148,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc5557efc453706fed5e4fa85006fe9817c224c3f480a34c7e5959fd700921c5" dependencies = [ - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3255,7 +3256,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3285,7 +3286,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.59", + "syn 2.0.60", "termcolor", "toml 0.8.12", "walkdir", @@ -3629,7 +3630,7 @@ dependencies = [ "prettier-please", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -3700,9 +3701,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" +checksum = "38793c55593b33412e3ae40c2c9781ffaa6f438f6f8c10f24e71846fbd7ae01e" [[package]] name = "file-per-thread-logger" @@ -3738,7 +3739,7 @@ dependencies = [ "log", "num-traits", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "scale-info", ] @@ -3772,9 +3773,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "4556222738635b7a3417ae6130d8f52201e45a0c4d1a907f0826383adb5f85e7" dependencies = [ "crc32fast", "libz-sys", @@ -4042,7 +4043,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing 13.0.0", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4055,7 +4056,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4066,7 +4067,7 @@ checksum = "d9c078db2242ea7265faa486004e7fd8daaf1a577cfcac0070ce55d926922883" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4223,7 +4224,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -4856,7 +4857,7 @@ dependencies = [ "http 0.2.12", "hyper 0.14.28", "log", - "rustls 0.21.10", + "rustls 0.21.11", "rustls-native-certs 0.6.3", "tokio", "tokio-rustls 0.24.1", @@ -5252,9 +5253,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -5525,7 +5526,7 @@ dependencies = [ "globset", "hyper 0.14.28", "jsonrpsee-types 0.16.3", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "rustc-hash", "serde", @@ -5692,7 +5693,7 @@ dependencies = [ "memchr", "num-cmp", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "percent-encoding", "regex", "reqwest", @@ -5788,7 +5789,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2" dependencies = [ "kvdb", - "parking_lot 0.12.1", + "parking_lot 0.12.2", ] [[package]] @@ -5799,7 +5800,7 @@ checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" dependencies = [ "kvdb", "num_cpus", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "regex", "rocksdb", "smallvec", @@ -5995,7 +5996,7 @@ dependencies = [ "multihash", "multistream-select", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project", "quick-protobuf", "rand 0.8.5", @@ -6015,7 +6016,7 @@ dependencies = [ "futures", "libp2p-core", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "smallvec", "trust-dns-resolver", ] @@ -6177,7 +6178,7 @@ dependencies = [ "libp2p-identity", "libp2p-tls", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "quinn-proto", "rand 0.8.5", "rustls 0.20.9", @@ -6293,7 +6294,7 @@ dependencies = [ "futures-rustls", "libp2p-core", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "quicksink", "rw-stream-sink", "soketto", @@ -6457,9 +6458,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -6564,7 +6565,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -6578,7 +6579,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -6589,7 +6590,7 @@ checksum = "9ea73aa640dc01d62a590d48c0c3521ed739d53b27f919b25c3551e233481654" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -6600,7 +6601,7 @@ checksum = "ef9d79ae96aaba821963320eb2b6e34d17df1e5a83d8a1985c29cc5be59577b3" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -6667,7 +6668,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -6845,7 +6846,7 @@ dependencies = [ "hashlink", "lioness", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "rand_chacha 0.3.1", "rand_distr", @@ -7549,7 +7550,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -7883,7 +7884,7 @@ dependencies = [ "log", "lz4", "memmap2", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "siphasher 0.3.11", "snap", @@ -7948,12 +7949,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", - "parking_lot_core 0.9.9", + "parking_lot_core 0.9.10", ] [[package]] @@ -7972,15 +7973,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", + "redox_syscall 0.5.1", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -8107,7 +8108,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8224,7 +8225,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8335,7 +8336,7 @@ dependencies = [ "opentelemetry 0.22.0", "opentelemetry-http", "opentelemetry-semantic-conventions", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "percent-encoding", "pin-project-lite 0.2.14", "poem-derive", @@ -8363,20 +8364,20 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] name = "polling" -version = "3.6.0" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c976a60b2d7e99d6f229e414670a9b85d13ac305cc6d1e9c134de58c5aaaf6" +checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.3.9", "pin-project-lite 0.2.14", - "rustix 0.38.32", + "rustix 0.38.34", "tracing", "windows-sys 0.52.0", ] @@ -8488,7 +8489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22020dfcf177fcc7bf5deaf7440af371400c67c0de14c399938d8ed4fb4645d3" dependencies = [ "proc-macro2", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8517,7 +8518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" dependencies = [ "proc-macro2", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8607,7 +8608,7 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8629,7 +8630,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "thiserror", ] @@ -8641,7 +8642,7 @@ checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" dependencies = [ "dtoa", "itoa", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus-client-derive-encode", ] @@ -8653,7 +8654,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8741,7 +8742,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -8856,9 +8857,9 @@ dependencies = [ [[package]] name = "psl" -version = "2.1.33" +version = "2.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a93553389d84c7a76edf270a88b43fc2dcbc6a1fed546dd2a0f99df5ed4444b6" +checksum = "fe63c1c8bb438205c1245719638a0b14fe6e3b33f4406ac36b4770a706655345" dependencies = [ "psl-types", ] @@ -8972,7 +8973,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51de85fb3fb6524929c8a2eb85e6b6d363de4e8c48f9e2c2eac4944abc181c93" dependencies = [ "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "scheduled-thread-pool", ] @@ -9170,6 +9171,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -9198,7 +9208,7 @@ checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -9288,7 +9298,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite 0.2.14", - "rustls 0.21.10", + "rustls 0.21.11", "rustls-pemfile 1.0.4", "serde", "serde_json", @@ -9498,7 +9508,7 @@ dependencies = [ "proc-macro2", "quote", "rust-embed-utils", - "syn 2.0.59", + "syn 2.0.60", "walkdir", ] @@ -9599,9 +9609,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -9624,9 +9634,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring 0.17.8", @@ -9636,14 +9646,14 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.3", "subtle 2.5.0", "zeroize", ] @@ -9694,9 +9704,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" [[package]] name = "rustls-webpki" @@ -9710,9 +9720,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -9896,7 +9906,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -9950,7 +9960,7 @@ dependencies = [ "futures", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-executor", "sc-transaction-pool-api", "sc-utils", @@ -9982,7 +9992,7 @@ dependencies = [ "log", "parity-db", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-client-api", "sc-state-db", "schnellru", @@ -10007,7 +10017,7 @@ dependencies = [ "libp2p-identity", "log", "mockall", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-client-api", "sc-utils", "serde", @@ -10067,7 +10077,7 @@ dependencies = [ "futures-timer", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "sc-block-builder", "sc-chain-spec", @@ -10124,7 +10134,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225f2ad733bc7234a6638d5203624194824b2f78ab631bc911223f536a66b9c8" dependencies = [ "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-executor-common", "sc-executor-wasmtime", "schnellru", @@ -10163,7 +10173,7 @@ dependencies = [ "cfg-if", "libc", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rustix 0.36.17", "sc-allocator", "sc-executor-common", @@ -10196,7 +10206,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abecdf9778fccc254c0b5e227ea8b90fd59247044a30ad293a068b180427d244" dependencies = [ "array-bytes 6.2.2", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "serde_json", "sp-application-crypto 27.0.0", "sp-core 25.0.0", @@ -10220,7 +10230,7 @@ dependencies = [ "mixnet", "multiaddr", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-client-api", "sc-network", "sc-transaction-pool-api", @@ -10254,7 +10264,7 @@ dependencies = [ "log", "mockall", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "partial_sort", "pin-project", "rand 0.8.5", @@ -10428,7 +10438,7 @@ dependencies = [ "num_cpus", "once_cell", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "sc-client-api", "sc-network", @@ -10465,7 +10475,7 @@ dependencies = [ "jsonrpsee 0.16.3", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -10538,7 +10548,7 @@ dependencies = [ "jsonrpsee 0.16.3", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-chain-spec", "sc-client-api", "sc-transaction-pool-api", @@ -10568,7 +10578,7 @@ dependencies = [ "jsonrpsee 0.16.3", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project", "rand 0.8.5", "sc-block-builder", @@ -10627,7 +10637,7 @@ checksum = "3635fe572adfe796886e18910c8b94f7ce67f9ae3e2c161176e122ddf0baa7e4" dependencies = [ "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sp-core 25.0.0", ] @@ -10639,7 +10649,7 @@ checksum = "58635973b3a8ca0a40c885b6bc1a61365e5424bf4312ef86963c799f50cfa15b" dependencies = [ "log", "parity-db", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-client-api", "sc-keystore", "sp-api", @@ -10681,7 +10691,7 @@ dependencies = [ "futures", "libp2p", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project", "rand 0.8.5", "sc-utils", @@ -10703,7 +10713,7 @@ dependencies = [ "lazy_static", "libc", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "regex", "rustc-hash", "sc-client-api", @@ -10730,7 +10740,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -10745,7 +10755,7 @@ dependencies = [ "linked-hash-map", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sc-client-api", "sc-transaction-pool-api", "sc-utils", @@ -10788,7 +10798,7 @@ dependencies = [ "futures-timer", "lazy_static", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus", "sp-arithmetic 20.0.0", ] @@ -10943,7 +10953,7 @@ dependencies = [ "proc-macro2", "quote", "scale-info", - "syn 2.0.59", + "syn 2.0.60", "thiserror", ] @@ -11003,7 +11013,7 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cbc66816425a074528352f5789333ecff06ca41b36b0b0efdfbb29edc391a19" dependencies = [ - "parking_lot 0.12.1", + "parking_lot 0.12.2", ] [[package]] @@ -11267,7 +11277,7 @@ checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -11453,9 +11463,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -11648,7 +11658,7 @@ dependencies = [ "log", "lru 0.12.3", "no-std-net 0.6.0", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project", "rand 0.8.5", "rand_chacha 0.3.1", @@ -11755,7 +11765,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -11837,7 +11847,7 @@ dependencies = [ "futures", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "schnellru", "sp-api", "sp-consensus", @@ -11955,7 +11965,7 @@ dependencies = [ "log", "merlin 2.0.1", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "paste", "primitive-types", "rand 0.8.5", @@ -12003,7 +12013,7 @@ dependencies = [ "log", "merlin 3.0.0", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "paste", "primitive-types", "rand 0.8.5", @@ -12076,7 +12086,7 @@ checksum = "42ce3e6931303769197da81facefa86159fa1085dcd96ecb7e7407b5b93582a0" dependencies = [ "quote", "sp-core-hashing 13.0.0", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -12086,7 +12096,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c6e8c710d6a71512af6f42d9dba9c3d1f6ad793846480babf459bbde3d60a94" dependencies = [ "kvdb", - "parking_lot 0.12.1", + "parking_lot 0.12.2", ] [[package]] @@ -12097,7 +12107,7 @@ checksum = "50535e1a5708d3ba5c1195b59ebefac61cc8679c2c24716b87a86e8b7ed2e4a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -12108,7 +12118,7 @@ checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -12231,7 +12241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b8ec5ebbba70bee83d79c3fe5e49f12df0a4bb6029858ddf9a15eea7539a592" dependencies = [ "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sp-core 25.0.0", "sp-externalities 0.23.0", "thiserror", @@ -12244,7 +12254,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96806a28a62ed9ddecd0b28857b1344d029390f7c5c42a2ff9199cbf5638635c" dependencies = [ "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "sp-core 28.0.0", "sp-externalities 0.25.0", "thiserror", @@ -12425,7 +12435,7 @@ dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -12439,7 +12449,7 @@ dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -12482,7 +12492,7 @@ dependencies = [ "hash-db", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "smallvec", "sp-core 25.0.0", @@ -12504,7 +12514,7 @@ dependencies = [ "hash-db", "log", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "smallvec", "sp-core 28.0.0", @@ -12667,7 +12677,7 @@ dependencies = [ "memory-db", "nohash-hasher", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "scale-info", "schnellru", @@ -12691,7 +12701,7 @@ dependencies = [ "memory-db", "nohash-hasher", "parity-scale-codec", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "scale-info", "schnellru", @@ -12731,7 +12741,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -12960,7 +12970,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -13114,7 +13124,7 @@ dependencies = [ "scale-info", "scale-typegen", "subxt-metadata", - "syn 2.0.59", + "syn 2.0.60", "thiserror", "tokio", ] @@ -13148,7 +13158,7 @@ dependencies = [ "quote", "scale-typegen", "subxt-codegen", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -13177,9 +13187,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.59" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", @@ -13265,7 +13275,7 @@ checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -13320,22 +13330,22 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -13488,7 +13498,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project-lite 0.2.14", "signal-hook-registry", "socket2 0.5.6", @@ -13515,7 +13525,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -13545,7 +13555,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.10", + "rustls 0.21.11", "tokio", ] @@ -13555,7 +13565,7 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.22.3", + "rustls 0.22.4", "rustls-pki-types", "tokio", ] @@ -13629,7 +13639,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.12", ] [[package]] @@ -13678,9 +13688,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.6", "serde", @@ -13813,7 +13823,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -14000,7 +14010,7 @@ dependencies = [ "ipconfig", "lazy_static", "lru-cache", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "resolv-conf", "smallvec", "thiserror", @@ -14441,7 +14451,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "wasm-bindgen-shared", ] @@ -14475,7 +14485,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -14593,9 +14603,9 @@ dependencies = [ [[package]] name = "wasmparser-nostd" -version = "0.100.1" +version = "0.100.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157cab83003221bfd385833ab587a039f5d6fa7304854042ba358a3b09e0724" +checksum = "d5a015fe95f3504a94bb1462c717aae75253e39b9dd6c3fb1062c934535c64aa" dependencies = [ "indexmap-nostd", ] @@ -14849,7 +14859,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -14892,11 +14902,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -15224,7 +15234,7 @@ checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" dependencies = [ "libc", "linux-raw-sys 0.4.13", - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -15236,7 +15246,7 @@ dependencies = [ "futures", "log", "nohash-hasher", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand 0.8.5", "static_assertions", ] @@ -15279,7 +15289,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] @@ -15299,7 +15309,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.60", ] [[package]] diff --git a/crates/api/src/chronicle_graphql/activity.rs b/crates/api/src/chronicle_graphql/activity.rs index 2dbc6055..99c68e6d 100644 --- a/crates/api/src/chronicle_graphql/activity.rs +++ b/crates/api/src/chronicle_graphql/activity.rs @@ -7,12 +7,14 @@ use common::prov::Role; use diesel::prelude::*; use std::collections::HashMap; +use crate::chronicle_graphql::DatabaseContext; + pub async fn namespace<'a>( namespaceid: i32, ctx: &Context<'a>, ) -> async_graphql::Result { use chronicle_persistence::schema::namespace::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -34,7 +36,7 @@ pub async fn was_associated_with<'a>( role: String, } - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; let delegation_entries = delegation::table @@ -94,7 +96,7 @@ pub async fn was_associated_with<'a>( pub async fn used<'a>(id: i32, ctx: &Context<'a>) -> async_graphql::Result> { use chronicle_persistence::schema::usage::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -114,7 +116,7 @@ pub async fn was_informed_by<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::wasinformedby::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -133,7 +135,7 @@ pub async fn was_informed_by<'a>( pub async fn generated<'a>(id: i32, ctx: &Context<'a>) -> async_graphql::Result> { use chronicle_persistence::schema::generation::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -153,7 +155,7 @@ pub async fn load_attribute<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::activity_attribute; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; diff --git a/crates/api/src/chronicle_graphql/agent.rs b/crates/api/src/chronicle_graphql/agent.rs index 62a7758c..1f5a14f1 100644 --- a/crates/api/src/chronicle_graphql/agent.rs +++ b/crates/api/src/chronicle_graphql/agent.rs @@ -6,12 +6,14 @@ use chronicle_persistence::{ use common::prov::Role; use diesel::prelude::*; +use crate::chronicle_graphql::DatabaseContext; + pub async fn namespace<'a>( namespace_id: i32, ctx: &Context<'a>, ) -> async_graphql::Result { use chronicle_persistence::schema::namespace::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -29,7 +31,7 @@ pub async fn acted_on_behalf_of<'a>( delegation::{self, dsl}, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -55,7 +57,7 @@ pub async fn attribution<'a>( entity as entity_dsl, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -77,7 +79,7 @@ pub async fn load_attribute<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::agent_attribute; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; diff --git a/crates/api/src/chronicle_graphql/authorization.rs b/crates/api/src/chronicle_graphql/authorization.rs index dfe5c69b..842d8715 100644 --- a/crates/api/src/chronicle_graphql/authorization.rs +++ b/crates/api/src/chronicle_graphql/authorization.rs @@ -42,9 +42,10 @@ pub enum Error { UnexpectedResponse { server: String, status: StatusCode }, } +#[derive(Clone)] pub struct TokenChecker { client: reqwest::Client, - verifier: Option, + verifier: Option>, jwks_uri: Option, userinfo_uri: Option, userinfo_cache: Arc>>>, @@ -60,11 +61,14 @@ impl TokenChecker { Self { client: reqwest::Client::new(), verifier: jwks_uri.map(|uri| { - RemoteJwksVerifier::new( - uri.full_uri(), - None, - Duration::from_secs(cache_expiry_seconds.into()), - ) + { + RemoteJwksVerifier::new( + uri.full_uri(), + None, + Duration::from_secs(cache_expiry_seconds.into()), + ) + } + .into() }), jwks_uri: jwks_uri.cloned(), userinfo_uri: userinfo_uri.cloned(), diff --git a/crates/api/src/chronicle_graphql/entity.rs b/crates/api/src/chronicle_graphql/entity.rs index b10a5bc8..2ba95118 100644 --- a/crates/api/src/chronicle_graphql/entity.rs +++ b/crates/api/src/chronicle_graphql/entity.rs @@ -6,6 +6,8 @@ use chronicle_persistence::{ use common::prov::{operations::DerivationType, Role}; use diesel::prelude::*; +use crate::chronicle_graphql::DatabaseContext; + async fn typed_derivation<'a>( id: i32, ctx: &Context<'a>, @@ -16,7 +18,7 @@ async fn typed_derivation<'a>( entity as entitydsl, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -35,7 +37,7 @@ pub async fn namespace<'a>( ) -> async_graphql::Result { use chronicle_persistence::schema::namespace::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -52,7 +54,7 @@ pub async fn was_attributed_to<'a>( ) -> async_graphql::Result)>> { use chronicle_persistence::schema::{agent, attribution}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; let res = attribution::table @@ -77,7 +79,7 @@ pub async fn was_generated_by<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::generation::{self, dsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -99,7 +101,7 @@ pub async fn was_derived_from<'a>( entity as entitydsl, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; @@ -133,7 +135,7 @@ pub async fn load_attribute<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::entity_attribute; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let mut connection = store.connection()?; diff --git a/crates/api/src/chronicle_graphql/mod.rs b/crates/api/src/chronicle_graphql/mod.rs index d1d139e0..1b1ba2a9 100644 --- a/crates/api/src/chronicle_graphql/mod.rs +++ b/crates/api/src/chronicle_graphql/mod.rs @@ -8,6 +8,7 @@ use async_graphql_poem::{ GraphQLWebSocket, }; +use crate::Store; use common::{ identity::{AuthId, IdentityError, JwtClaims, OpaData, SignedIdentity}, ledger::{SubmissionError, SubmissionStage}, @@ -56,7 +57,7 @@ use crate::{ApiDispatch, ApiError, StoreError}; #[macro_use] pub mod activity; pub mod agent; -mod authorization; +pub mod authorization; mod cursor_project; pub mod entity; pub mod mutation; @@ -192,19 +193,6 @@ impl ErrorExtensions for GraphQlError { } } -#[derive(Derivative)] -#[derivative(Debug)] -pub struct Store { - #[derivative(Debug = "ignore")] - pub pool: Pool>, -} - -impl Store { - pub fn new(pool: Pool>) -> Self { - Store { pool } - } -} - pub struct Commit { pub tx_id: String, } @@ -453,6 +441,18 @@ impl SecurityConf { ) -> Self { Self { jwks_uri, userinfo_uri, id_claims, jwt_must_claim, allow_anonymous, opa } } + + pub fn as_endpoint_conf(&self, cache_expiry_seconds: u32) -> EndpointSecurityConfiguration { + EndpointSecurityConfiguration::new( + TokenChecker::new( + self.jwks_uri.as_ref(), + self.userinfo_uri.as_ref(), + cache_expiry_seconds, + ), + self.jwt_must_claim.clone(), + self.allow_anonymous, + ) + } } #[async_trait::async_trait] @@ -576,14 +576,15 @@ async fn execute_opa_check( } } -struct EndpointSecurityConfiguration { +#[derive(Clone)] +pub struct EndpointSecurityConfiguration { checker: TokenChecker, - must_claim: HashMap, - allow_anonymous: bool, + pub must_claim: HashMap, + pub allow_anonymous: bool, } impl EndpointSecurityConfiguration { - fn new( + pub fn new( checker: TokenChecker, must_claim: HashMap, allow_anonymous: bool, @@ -984,6 +985,51 @@ async fn await_shutdown() { let _permit = SHUTDOWN_SIGNAL.acquire().await.unwrap(); } + +#[derive(Clone)] +struct DatabaseContext { + pool: Pool>, +} + +impl DatabaseContext { + fn new(pool: &Pool>) -> Result { + Ok(DatabaseContext { pool: pool.clone() }) + } + + fn connection(&self) -> Result>, r2d2::Error> { + self.pool.get() + } +} + +pub fn construct_schema( + query: Query, + mutation: Mutation, + subscription: Subscription, + claim_parser: Option, + pool: &Pool>, + api: &ApiDispatch, + opa: ExecutorContext, +) -> Result, StoreError> +where + Query: ObjectType + Copy + 'static, + Mutation: ObjectType + Copy + 'static, + Subscription: SubscriptionType + 'static, +{ + let mut schema = Schema::build(query, mutation, subscription) + .extension(OpaCheck { claim_parser: claim_parser.clone() }); + + if let Some(claim_parser) = &claim_parser { + schema = schema.extension(claim_parser.clone()); + } + + Ok(schema + .data(api.clone()) + .data(opa.clone()) + .data(AuthId::anonymous()) + .data(DatabaseContext::new(pool)?) + .finish()) +} + #[async_trait::async_trait] impl ChronicleApiServer for ChronicleGraphQl where @@ -1004,19 +1050,16 @@ where let claim_parser = sec .id_claims .map(|id_claims| AuthFromJwt { id_claims, allow_anonymous: sec.allow_anonymous }); - let mut schema = Schema::build(self.query, self.mutation, Subscription) - //TODO: update - // .extension(OpenTelemetry::new(opentelemetry::global::tracer("chronicle-api-gql"))) - .extension(OpaCheck { claim_parser: claim_parser.clone() }); - if let Some(claim_parser) = &claim_parser { - schema = schema.extension(claim_parser.clone()); - } - let schema = schema - .data(Store::new(pool.clone())) - .data(api) - .data(sec.opa.clone()) - .data(AuthId::anonymous()) - .finish(); + + let schema = construct_schema( + self.query, + self.mutation, + Subscription, + claim_parser.clone(), + &pool, + &api, + sec.opa.clone(), + )?; let iri_endpoint = |secconf| IriEndpoint { secconf, diff --git a/crates/api/src/chronicle_graphql/mutation.rs b/crates/api/src/chronicle_graphql/mutation.rs index 9d11ea7a..bf63e42e 100644 --- a/crates/api/src/chronicle_graphql/mutation.rs +++ b/crates/api/src/chronicle_graphql/mutation.rs @@ -31,9 +31,9 @@ async fn derivation<'a>( used_entity: EntityId, derivation: DerivationType, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".into()).into(); @@ -59,9 +59,9 @@ pub async fn agent<'a>( namespace: Option, attributes: Attributes, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()); @@ -85,9 +85,9 @@ pub async fn activity<'a>( namespace: Option, attributes: Attributes, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()); @@ -111,9 +111,9 @@ pub async fn entity<'a>( namespace: Option, attributes: Attributes, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()); @@ -139,9 +139,9 @@ pub async fn acted_on_behalf_of<'a>( activity_id: Option, role: Option, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -202,9 +202,9 @@ pub async fn start_activity<'a>( agent: Option, // deprecated, slated for removal in CHRON-185 time: Option>, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -225,9 +225,9 @@ pub async fn end_activity<'a>( agent: Option, // deprecated, slated for removal in CHRON-185 time: Option>, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -248,9 +248,9 @@ pub async fn instant_activity<'a>( agent: Option, // deprecated, slated for removal in CHRON-185 time: Option>, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -271,9 +271,9 @@ pub async fn was_associated_with<'a>( activity: ActivityId, role: Option, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -299,9 +299,9 @@ pub async fn was_attributed_to<'a>( id: EntityId, role: Option, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -321,9 +321,9 @@ pub async fn used<'a>( entity: EntityId, namespace: Option, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -343,9 +343,9 @@ pub async fn was_informed_by<'a>( informing_activity: ActivityId, namespace: Option, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); @@ -369,9 +369,9 @@ pub async fn was_generated_by<'a>( entity: EntityId, namespace: Option, ) -> async_graphql::Result { - let api = ctx.data_unchecked::(); + let api = ctx.data::()?; - let identity = ctx.data_unchecked::().to_owned(); + let identity = ctx.data::()?.to_owned(); let namespace = namespace.unwrap_or_else(|| "default".to_owned()).into(); diff --git a/crates/api/src/chronicle_graphql/query.rs b/crates/api/src/chronicle_graphql/query.rs index e8b97058..e141c8db 100644 --- a/crates/api/src/chronicle_graphql/query.rs +++ b/crates/api/src/chronicle_graphql/query.rs @@ -6,13 +6,15 @@ use chrono::{DateTime, NaiveDate, TimeZone, Utc}; use diesel::{debug_query, pg::Pg, prelude::*}; use tracing::{debug, instrument}; +use crate::chronicle_graphql::DatabaseContext; + use super::{cursor_project::project_to_nodes, GraphQlError, Store, TimelineOrder}; use chronicle_persistence::{ cursor::Cursorize, queryable::{Activity, Agent, Entity}, schema::generation, }; -use common::prov::{ActivityId, AgentId, DomaintypeId, EntityId, ExternalIdPart}; +use common::{identity::AuthId, prov::{ActivityId, AgentId, DomaintypeId, EntityId, ExternalIdPart}}; #[allow(clippy::too_many_arguments)] #[instrument(skip(ctx))] @@ -35,9 +37,9 @@ pub async fn activity_timeline<'a>( wasinformedby, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; let ns = namespace.unwrap_or_else(|| "default".into()); // Default from and to to the maximum possible time range @@ -139,9 +141,9 @@ pub async fn entities_by_type<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::{entity, namespace::dsl as nsdsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; let ns = namespace.unwrap_or_else(|| "default".into()); let sql_query = entity::table @@ -180,9 +182,9 @@ pub async fn activities_by_type<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::{activity, namespace::dsl as nsdsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; let ns = namespace.unwrap_or_else(|| "default".into()); let sql_query = @@ -220,9 +222,9 @@ pub async fn agents_by_type<'a>( ) -> async_graphql::Result> { use chronicle_persistence::schema::{agent, namespace::dsl as nsdsl}; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; let ns = namespace.unwrap_or_else(|| "default".into()); let sql_query = agent::table @@ -259,10 +261,10 @@ pub async fn agent_by_id<'a>( namespace::dsl as nsdsl, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let ns = namespace.unwrap_or_else(|| "default".into()); - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; Ok(agent::table .inner_join(nsdsl::namespace) @@ -282,10 +284,10 @@ pub async fn activity_by_id<'a>( namespace::dsl as nsdsl, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let ns = namespace.unwrap_or_else(|| "default".into()); - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; Ok(activity::table .inner_join(nsdsl::namespace) @@ -305,9 +307,9 @@ pub async fn entity_by_id<'a>( namespace::dsl as nsdsl, }; - let store = ctx.data_unchecked::(); + let store = ctx.data::()?; let ns = namespace.unwrap_or_else(|| "default".into()); - let mut connection = store.pool.get()?; + let mut connection = store.connection()?; Ok(entity::table .inner_join(nsdsl::namespace) diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 1e742674..00c0155e 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -2,6 +2,7 @@ pub mod chronicle_graphql; pub mod commands; +pub use chronicle_persistence::Store; use chronicle_signing::{ChronicleKnownKeyNamesSigner, ChronicleSigning, SecretError}; use chrono::{DateTime, Utc}; @@ -28,7 +29,7 @@ use diesel_migrations::MigrationHarness; use futures::{select, FutureExt, StreamExt}; pub use chronicle_persistence::StoreError; -use chronicle_persistence::{Store, MIGRATIONS}; +use chronicle_persistence::MIGRATIONS; use diesel::r2d2::Pool; use metrics::histogram; use metrics_exporter_prometheus::PrometheusBuilder; diff --git a/crates/chronicle-arrow/src/lib.rs b/crates/chronicle-arrow/src/lib.rs index 0dce7675..7755605e 100644 --- a/crates/chronicle-arrow/src/lib.rs +++ b/crates/chronicle-arrow/src/lib.rs @@ -2,6 +2,7 @@ mod meta; mod operations; mod peekablestream; mod query; +use api::chronicle_graphql::EndpointSecurityConfiguration; use lazy_static::lazy_static; use tokio::sync::broadcast; @@ -27,7 +28,7 @@ use diesel::{r2d2::ConnectionManager, PgConnection}; use futures::{ future::join_all, stream::{self, BoxStream}, - FutureExt, StreamExt, TryFutureExt, TryStreamExt, + FutureExt, StreamExt, }; use meta::{DomainTypeMeta, Term}; @@ -171,7 +172,7 @@ pub async fn calculate_count_by_metadata_term( .and_then(|res| res.map_err(|e| Status::from_error(e.into()))) } -pub async fn create_flight_info_for_type( +async fn create_flight_info_for_type( pool: Arc>>, domain_items: Vec, term: Term, @@ -234,6 +235,7 @@ pub struct FlightServiceImpl { pool: r2d2::Pool>, api: ApiDispatch, record_batch_size: usize, + security: EndpointSecurityConfiguration, } impl FlightServiceImpl { @@ -241,9 +243,16 @@ impl FlightServiceImpl { domain: &common::domain::ChronicleDomainDef, pool: &r2d2::Pool>, api: &ApiDispatch, + security: EndpointSecurityConfiguration, record_batch_size: usize, ) -> Self { - Self { domain: domain.clone(), pool: pool.clone(), api: api.clone(), record_batch_size } + Self { + domain: domain.clone(), + pool: pool.clone(), + api: api.clone(), + security, + record_batch_size, + } } } @@ -643,18 +652,20 @@ pub async fn await_shutdown() { SHUTDOWN_CHANNEL.0.subscribe().recv().await.ok(); } -#[instrument(skip(pool, api))] +#[instrument(skip(pool, api, security))] pub async fn run_flight_service( domain: &common::domain::ChronicleDomainDef, pool: &Pool>, api: &ApiDispatch, + security: EndpointSecurityConfiguration, addrs: &Vec, record_batch_size: usize, ) -> Result<(), tonic::transport::Error> { meta::cache_domain_schemas(domain); let mut services = vec![]; for addr in addrs { - let flight_service = FlightServiceImpl::new(domain, pool, api, record_batch_size); + let flight_service = + FlightServiceImpl::new(domain, pool, api, security.clone(), record_batch_size); info!("Starting flight service at {}", addr); @@ -675,7 +686,10 @@ pub async fn run_flight_service( #[cfg(test)] mod tests { - use api::commands::{ApiCommand, ImportCommand}; + use api::{ + chronicle_graphql::{authorization::TokenChecker, EndpointSecurityConfiguration}, + commands::{ApiCommand, ImportCommand}, + }; use arrow_array::RecordBatch; use arrow_flight::{ decode::FlightRecordBatchStream, flight_service_client::FlightServiceClient, Criteria, @@ -696,7 +710,7 @@ mod tests { use futures::{pin_mut, stream, StreamExt}; use portpicker::pick_unused_port; - use std::{net::SocketAddr, time::Duration}; + use std::{collections::HashMap, net::SocketAddr, time::Duration}; use tonic::{transport::Channel, Request, Status}; use uuid::Uuid; @@ -704,7 +718,8 @@ mod tests { meta::{cache_domain_schemas, get_domain_type_meta_from_cache, DomainTypeMeta}, query::{ ActedOnBehalfOfRef, ActivityAndReferences, ActivityAssociationRef, AgentAndReferences, - AgentAttributionRef, DerivationRef, EntityAndReferences, EntityAttributionRef, + AgentAttributionRef, AgentInteraction, DerivationRef, EntityAndReferences, + EntityAttributionRef, }, }; @@ -722,9 +737,20 @@ mod tests { let dispatch = api.api_dispatch().clone(); let domain = domain.clone(); tokio::spawn(async move { - super::run_flight_service(&domain, &pool, &dispatch, &vec![addr], 10) - .await - .unwrap(); + super::run_flight_service( + &domain, + &pool, + &dispatch, + EndpointSecurityConfiguration::new( + TokenChecker::new(None, None, 30), + HashMap::default(), + true, + ), + &vec![addr], + 10, + ) + .await + .unwrap(); }); tokio::time::sleep(Duration::from_secs(5)).await; @@ -822,41 +848,41 @@ roles: ], was_derived_from: vec![ DerivationRef { - target: format!("entity-d-{}", i), + source: format!("entity-d-{}", i), activity: format!("activity-d-{}", i), }, DerivationRef { - target: format!("entity-d-{}", i), + source: format!("entity-d-{}", i), activity: format!("activity-d-{}", i), }, ], was_quoted_from: vec![ DerivationRef { - target: format!("entity-q-{}", i), + source: format!("entity-q-{}", i), activity: format!("activity-q-{}", i), }, DerivationRef { - target: format!("entity-q-{}", i), + source: format!("entity-q-{}", i), activity: format!("activity-q-{}", i), }, ], was_revision_of: vec![ DerivationRef { - target: format!("entity-r-{}", i), + source: format!("entity-r-{}", i), activity: format!("activity-r-{}", i), }, DerivationRef { - target: format!("entity-r-{}", i), + source: format!("entity-r-{}", i), activity: format!("activity-r-{}", i), }, ], had_primary_source: vec![ DerivationRef { - target: format!("entity-ps-{}", i), + source: format!("entity-ps-{}", i), activity: format!("activity-ps-{}", i), }, DerivationRef { - target: format!("entity-ps-{}", i), + source: format!("entity-ps-{}", i), activity: format!("activity-ps-{}", i), }, ], @@ -885,10 +911,14 @@ roles: generated: vec![format!("entity-{}", i), format!("entity-{}", i + 1)], was_informed_by: vec![format!("activity-{}", i), format!("activity-{}", i + 1)], was_associated_with: vec![ActivityAssociationRef { - responsible_agent: format!("agent-{}", i), - responsible_role: Some("CERTIFIER".to_string()), - delegate_agent: Some(format!("agent-{}", i + 1)), - delegate_role: Some("MANUFACTURER".to_string()), + responsible: AgentInteraction { + agent: format!("agent-{}", i), + role: Some("ROLE_TYPE".to_string()), + }, + delegated: vec![AgentInteraction { + agent: format!("delegated-agent-{}", i), + role: Some("DELEGATED_ROLE".to_string()), + }], }], used: vec![format!("entity-{}", i), format!("entity-{}", i + 1)], }; @@ -913,12 +943,12 @@ roles: attributes: create_attributes(meta.typ.as_deref(), &attributes), acted_on_behalf_of: vec![ActedOnBehalfOfRef { agent: format!("agent-{}", i), - role: Some("CERTIFIER".to_string()), - activity: Some(format!("activity-{}", i)), + role: Some("DELEGATED_CERTIFIER".to_string()), + activity: format!("activity-{}", i), }], was_attributed_to: vec![AgentAttributionRef { entity: format!("entity-{}", i), - role: Some("CERTIFIER".to_string()), + role: Some("UNSPECIFIED_INTERACTION".to_string()), }], }; agents.push(agent); @@ -1118,7 +1148,7 @@ roles: insta::assert_debug_snapshot!(flights, @r###" [ FlightInfo { - schema: b"\xff\xff\xff\xff\xb8\x03\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\t\0\0\0P\x03\0\0\x0c\x03\0\0\xe4\x02\0\0\xa0\x02\0\0T\x02\0\0\xfc\x01\0\0\xa0\x01\0\0@\x01\0\0\x04\0\0\0\xe4\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x10\x01\0\0\x01\0\0\0\x08\0\0\0\xd8\xfc\xff\xff\x04\xfd\xff\xff$\0\0\0\x0c\0\0\0\0\0\0\r\xe4\0\0\0\x04\0\0\0\xa8\0\0\0p\0\0\0<\0\0\0\x08\0\0\0\x04\xfd\xff\xff\xd4\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0 \xfd\xff\xff\r\0\0\0delegate_role\0\0\0\x04\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0P\xfd\xff\xff\x0e\0\0\0delegate_agent\0\04\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x80\xfd\xff\xff\x10\0\0\0responsible_role\0\0\0\0\xc4\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xb4\xfd\xff\xff\x11\0\0\0responsible_agent\0\0\0\x04\0\0\0item\0\0\0\0\x13\0\0\0was_associated_with\0\x1c\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\x10\xfe\xff\xff<\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0,\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_informed_by\0\x1c\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\x01\x0c8\0\0\0\x01\0\0\0\x08\0\0\0l\xfe\xff\xff\x98\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x88\xfe\xff\xff\x04\0\0\0item\0\0\0\0\t\0\0\0generated\0\0\0t\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\x01\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\xc4\xfe\xff\xff\xf0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xe0\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x04\0\0\0used\0\0\0\0\xc8\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\n\x1c\0\0\0\0\0\0\0\xb8\xff\xff\xff\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x05\0\0\0ended\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x1c\0\0\0\x0c\0\0\0\0\0\x01\n$\0\0\0\0\0\0\0\x08\0\x0c\0\n\0\x04\0\x08\0\0\0\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x07\0\0\0started\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0", + schema: b"\xff\xff\xff\xff8\x04\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\t\0\0\0\xb4\x03\0\0p\x03\0\0H\x03\0\0\x04\x03\0\0\xb8\x02\0\0`\x02\0\0\x04\x02\0\0\xa4\x01\0\0\x04\0\0\0\x80\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0ct\x01\0\0\x01\0\0\0\x08\0\0\0t\xfc\xff\xffD\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\x01\rH\x01\0\0\x02\0\0\0\xbc\0\0\0\x08\0\0\0\x98\xfc\xff\xff\xc4\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0\xb8\xfc\xff\xff\x88\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\x01\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0\xdc\xfc\xff\xff\xac\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\xf8\xfc\xff\xff\x04\0\0\0role\0\0\0\00\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0 \xfd\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\t\0\0\0delegated\0\0\0t\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0l\xfd\xff\xff<\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x88\xfd\xff\xff\x04\0\0\0role\0\0\0\0\xc0\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xb0\xfd\xff\xff\x05\0\0\0agent\0\0\0\x0b\0\0\0responsible\0\x04\0\0\0item\0\0\0\0\x13\0\0\0was_associated_with\0\x1c\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\x10\xfe\xff\xff<\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0,\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_informed_by\0x\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0l\xfe\xff\xff\x98\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x88\xfe\xff\xff\x04\0\0\0item\0\0\0\0\t\0\0\0generated\0\0\0\xd0\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\xc4\xfe\xff\xff\xf0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xe0\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x04\0\0\0used\0\0\0\0\xc8\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\n\x1c\0\0\0\0\0\0\0\xb8\xff\xff\xff\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x05\0\0\0ended\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x1c\0\0\0\x0c\0\0\0\0\0\x01\n$\0\0\0\0\0\0\0\x08\0\x0c\0\n\0\x04\0\x08\0\0\0\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x07\0\0\0started\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", flight_descriptor: Some( FlightDescriptor { r#type: Path, @@ -1135,7 +1165,7 @@ roles: ordered: false, }, FlightInfo { - schema: b"\xff\xff\xff\xff\xf8\x03\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\n\0\0\0\x88\x03\0\0D\x03\0\0\x1c\x03\0\0\xe4\x02\0\0\x90\x02\0\0T\x02\0\0\xfc\x01\0\0\xa0\x01\0\0@\x01\0\0\x04\0\0\0\xb0\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x10\x01\0\0\x01\0\0\0\x08\0\0\0\xa4\xfc\xff\xff\xd0\xfc\xff\xff$\0\0\0\x0c\0\0\0\0\0\0\r\xe4\0\0\0\x04\0\0\0\xa8\0\0\0p\0\0\0<\0\0\0\x08\0\0\0\xd0\xfc\xff\xff\x94\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\xec\xfc\xff\xff\r\0\0\0delegate_role\0\0\0\xc4\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x1c\xfd\xff\xff\x0e\0\0\0delegate_agent\0\0\xf4\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0L\xfd\xff\xff\x10\0\0\0responsible_role\0\0\0\0\x90\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x80\xfd\xff\xff\x11\0\0\0responsible_agent\0\0\0\x04\0\0\0item\0\0\0\0\x13\0\0\0was_associated_with\0\xe8\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\xdc\xfd\xff\xff\x08\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xf8\xfd\xff\xff\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_informed_by\0\xdc\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\x01\x0c8\0\0\0\x01\0\0\0\x08\0\0\08\xfe\xff\xffd\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0T\xfe\xff\xff\x04\0\0\0item\0\0\0\0\t\0\0\0generated\0\0\04\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\x01\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\x90\xfe\xff\xff\xbc\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xac\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x04\0\0\0used\0\0\0\0\x88\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\n\x1c\0\0\0\0\0\0\0\xc8\xff\xff\xff\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x05\0\0\0ended\0\0\0\xc0\xff\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\x01\n$\0\0\0\0\0\0\0\x08\0\x0c\0\n\0\x04\0\x08\0\0\0\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x07\0\0\0started\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0h\xff\xff\xff\x10\0\0\0batchIDAttribute\0\0\0\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + schema: b"\xff\xff\xff\xffx\x04\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\n\0\0\0\xec\x03\0\0\xa8\x03\0\0\x80\x03\0\0H\x03\0\0\xf4\x02\0\0\xb8\x02\0\0`\x02\0\0\x04\x02\0\0\xa4\x01\0\0\x04\0\0\0L\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0ct\x01\0\0\x01\0\0\0\x08\0\0\0@\xfc\xff\xff\x04\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\x01\rH\x01\0\0\x02\0\0\0\xbc\0\0\0\x08\0\0\0d\xfc\xff\xff\x90\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0\x84\xfc\xff\xffH\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\x01\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0\xa8\xfc\xff\xffl\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\xc4\xfc\xff\xff\x04\0\0\0role\0\0\0\0\xfc\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xec\xfc\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\t\0\0\0delegated\0\0\0@\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\08\xfd\xff\xff\xfc\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0T\xfd\xff\xff\x04\0\0\0role\0\0\0\0\x8c\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0|\xfd\xff\xff\x05\0\0\0agent\0\0\0\x0b\0\0\0responsible\0\x04\0\0\0item\0\0\0\0\x13\0\0\0was_associated_with\0\xe8\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\xdc\xfd\xff\xff\x08\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xf8\xfd\xff\xff\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_informed_by\0D\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\08\xfe\xff\xffd\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0T\xfe\xff\xff\x04\0\0\0item\0\0\0\0\t\0\0\0generated\0\0\0\x9c\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\x90\xfe\xff\xff\xbc\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xac\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x04\0\0\0used\0\0\0\0\x88\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\n\x1c\0\0\0\0\0\0\0\xc8\xff\xff\xff\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x05\0\0\0ended\0\0\0\xc0\xff\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\x01\n$\0\0\0\0\0\0\0\x08\0\x0c\0\n\0\x04\0\x08\0\0\0\x08\0\0\0\0\0\x03\0\x03\0\0\0UTC\0\x07\0\0\0started\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0h\xff\xff\xff\x10\0\0\0batchIDAttribute\0\0\0\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", flight_descriptor: Some( FlightDescriptor { r#type: Path, @@ -1177,7 +1207,7 @@ roles: ordered: false, }, FlightInfo { - schema: b"\xff\xff\xff\xff8\x02\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\x07\0\0\0\xbc\x01\0\0x\x01\0\0P\x01\0\0\x14\x01\0\0\xcc\0\0\0h\0\0\0\x04\0\0\0p\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0d\xfe\xff\xff\x90\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x80\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x11\0\0\0was_attributed_to\0\0\0l\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\x01\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\xc4\xfe\xff\xff\xf0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xe0\xfe\xff\xff\x04\0\0\0item\0\0\0\0\x12\0\0\0acted_on_behalf_of\0\0\xcc\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0 \xff\xff\xff\x11\0\0\0locationAttribute\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0d\xff\xff\xff\x14\0\0\0companyNameAttribute\0\0\0\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", + schema: b"\xff\xff\xff\xff8\x03\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\x07\0\0\0\x9c\x02\0\0X\x02\0\00\x02\0\0\xf4\x01\0\0\xac\x01\0\0\xc0\0\0\0\x04\0\0\0\x90\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0\x84\xfd\xff\xff\xb0\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0\xa8\xfd\xff\xffp\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\xc4\xfd\xff\xff\x04\0\0\0role\0\0\0\0\xfc\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xec\xfd\xff\xff\x06\0\0\0entity\0\0\x04\0\0\0item\0\0\0\0\x11\0\0\0was_attributed_to\0\0\0H\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\xc0\0\0\0\x01\0\0\0\x08\0\0\0<\xfe\xff\xffh\xfe\xff\xff \0\0\0\x0c\0\0\0\0\0\0\r\x94\0\0\0\x03\0\0\0d\0\0\04\0\0\0\x08\0\0\0d\xfe\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x80\xfe\xff\xff\x04\0\0\0role\0\0\0\0\xb8\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xa8\xfe\xff\xff\x08\0\0\0activity\0\0\0\0\xe4\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xd4\xfe\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\x12\0\0\0acted_on_behalf_of\0\0\xcc\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0 \xff\xff\xff\x11\0\0\0locationAttribute\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0d\xff\xff\xff\x14\0\0\0companyNameAttribute\0\0\0\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", flight_descriptor: Some( FlightDescriptor { r#type: Path, @@ -1219,7 +1249,7 @@ roles: ordered: false, }, FlightInfo { - schema: b"\xff\xff\xff\xff8\x05\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\n\0\0\0\xcc\x04\0\0\x88\x04\0\0`\x04\0\0,\x04\0\0\xb8\x03\0\0\xfc\x02\0\0<\x02\0\0|\x01\0\0\xc0\0\0\0\x04\0\0\0l\xfb\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0`\xfb\xff\xff\x8c\xfb\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\x84\xfb\xff\xff\xb0\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xa0\xfb\xff\xff\x08\0\0\0activity\0\0\0\0\xdc\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfb\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_revision_of\0$\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x18\xfc\xff\xffD\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0<\xfc\xff\xffh\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0X\xfc\xff\xff\x08\0\0\0activity\0\0\0\0\x94\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x84\xfc\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_quoted_from\0\xdc\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\xd0\xfc\xff\xff\xfc\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xf4\xfc\xff\xff \xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x10\xfd\xff\xff\x08\0\0\0activity\0\0\0\0L\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0<\xfd\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x12\0\0\0had_primary_source\0\0\x98\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x8c\xfd\xff\xff\xb8\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xb0\xfd\xff\xff\xdc\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfd\xff\xff\x08\0\0\0activity\0\0\0\0\x08\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xf8\xfd\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x10\0\0\0was_derived_from\0\0\0\0T\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0H\xfe\xff\xfft\xfe\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0l\xfe\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x88\xfe\xff\xff\x04\0\0\0role\0\0\0\0\xc0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xb0\xfe\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\x11\0\0\0was_attributed_to\0\0\0\x0c\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\0\xff\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x1c\xff\xff\xff\x04\0\0\0item\0\0\0\0\x10\0\0\0was_generated_by\0\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0l\xff\xff\xff\x0f\0\0\0certIDAttribute\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0", + schema: b"\xff\xff\xff\xff8\x05\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\n\0\0\0\xcc\x04\0\0\x88\x04\0\0`\x04\0\0,\x04\0\0\xb8\x03\0\0\xfc\x02\0\0<\x02\0\0|\x01\0\0\xc0\0\0\0\x04\0\0\0l\xfb\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0`\xfb\xff\xff\x8c\xfb\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\x84\xfb\xff\xff\xb0\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xa0\xfb\xff\xff\x08\0\0\0activity\0\0\0\0\xdc\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfb\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_revision_of\0$\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x18\xfc\xff\xffD\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0<\xfc\xff\xffh\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0X\xfc\xff\xff\x08\0\0\0activity\0\0\0\0\x94\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x84\xfc\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_quoted_from\0\xdc\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\xd0\xfc\xff\xff\xfc\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xf4\xfc\xff\xff \xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x10\xfd\xff\xff\x08\0\0\0activity\0\0\0\0L\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0<\xfd\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x12\0\0\0had_primary_source\0\0\x98\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x8c\xfd\xff\xff\xb8\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xb0\xfd\xff\xff\xdc\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfd\xff\xff\x08\0\0\0activity\0\0\0\0\x08\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xf8\xfd\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x10\0\0\0was_derived_from\0\0\0\0T\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0H\xfe\xff\xfft\xfe\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0l\xfe\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x88\xfe\xff\xff\x04\0\0\0role\0\0\0\0\xc0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xb0\xfe\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\x11\0\0\0was_attributed_to\0\0\0\x0c\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\0\xff\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x1c\xff\xff\xff\x04\0\0\0item\0\0\0\0\x10\0\0\0was_generated_by\0\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0l\xff\xff\xff\x0f\0\0\0certIDAttribute\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0", flight_descriptor: Some( FlightDescriptor { r#type: Path, @@ -1261,7 +1291,7 @@ roles: ordered: false, }, FlightInfo { - schema: b"\xff\xff\xff\xff8\x05\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\n\0\0\0\xcc\x04\0\0\x88\x04\0\0`\x04\0\0,\x04\0\0\xb8\x03\0\0\xfc\x02\0\0<\x02\0\0|\x01\0\0\xc0\0\0\0\x04\0\0\0l\xfb\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0`\xfb\xff\xff\x8c\xfb\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\x84\xfb\xff\xff\xb0\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xa0\xfb\xff\xff\x08\0\0\0activity\0\0\0\0\xdc\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfb\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_revision_of\0$\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x18\xfc\xff\xffD\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0<\xfc\xff\xffh\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0X\xfc\xff\xff\x08\0\0\0activity\0\0\0\0\x94\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x84\xfc\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_quoted_from\0\xdc\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\xd0\xfc\xff\xff\xfc\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xf4\xfc\xff\xff \xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x10\xfd\xff\xff\x08\0\0\0activity\0\0\0\0L\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0<\xfd\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x12\0\0\0had_primary_source\0\0\x98\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x8c\xfd\xff\xff\xb8\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xb0\xfd\xff\xff\xdc\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfd\xff\xff\x08\0\0\0activity\0\0\0\0\x08\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xf8\xfd\xff\xff\x06\0\0\0target\0\0\x04\0\0\0item\0\0\0\0\x10\0\0\0was_derived_from\0\0\0\0T\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0H\xfe\xff\xfft\xfe\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0l\xfe\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x88\xfe\xff\xff\x04\0\0\0role\0\0\0\0\xc0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xb0\xfe\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\x11\0\0\0was_attributed_to\0\0\0\x0c\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\0\xff\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x1c\xff\xff\xff\x04\0\0\0item\0\0\0\0\x10\0\0\0was_generated_by\0\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0l\xff\xff\xff\x0f\0\0\0partIDAttribute\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0", + schema: b"\xff\xff\xff\xff8\x05\0\0\x10\0\0\0\0\0\n\0\x0c\0\n\0\t\0\x04\0\n\0\0\0\x10\0\0\0\0\x01\x04\0\x08\0\x08\0\0\0\x04\0\x08\0\0\0\x04\0\0\0\n\0\0\0\xcc\x04\0\0\x88\x04\0\0`\x04\0\0,\x04\0\0\xb8\x03\0\0\xfc\x02\0\0<\x02\0\0|\x01\0\0\xc0\0\0\0\x04\0\0\0l\xfb\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0`\xfb\xff\xff\x8c\xfb\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\x84\xfb\xff\xff\xb0\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xa0\xfb\xff\xff\x08\0\0\0activity\0\0\0\0\xdc\xfb\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfb\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_revision_of\0$\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x18\xfc\xff\xffD\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0<\xfc\xff\xffh\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0X\xfc\xff\xff\x08\0\0\0activity\0\0\0\0\x94\xfc\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x84\xfc\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x0f\0\0\0was_quoted_from\0\xdc\xfc\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\xd0\xfc\xff\xff\xfc\xfc\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xf4\xfc\xff\xff \xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x10\xfd\xff\xff\x08\0\0\0activity\0\0\0\0L\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0<\xfd\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x12\0\0\0had_primary_source\0\0\x98\xfd\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x94\0\0\0\x01\0\0\0\x08\0\0\0\x8c\xfd\xff\xff\xb8\xfd\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rh\0\0\0\x02\0\0\08\0\0\0\x08\0\0\0\xb0\xfd\xff\xff\xdc\xfd\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xcc\xfd\xff\xff\x08\0\0\0activity\0\0\0\0\x08\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xf8\xfd\xff\xff\x06\0\0\0source\0\0\x04\0\0\0item\0\0\0\0\x10\0\0\0was_derived_from\0\0\0\0T\xfe\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c\x90\0\0\0\x01\0\0\0\x08\0\0\0H\xfe\xff\xfft\xfe\xff\xff\x1c\0\0\0\x0c\0\0\0\0\0\0\rd\0\0\0\x02\0\0\04\0\0\0\x08\0\0\0l\xfe\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0\x88\xfe\xff\xff\x04\0\0\0role\0\0\0\0\xc0\xfe\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xb0\xfe\xff\xff\x05\0\0\0agent\0\0\0\x04\0\0\0item\0\0\0\0\x11\0\0\0was_attributed_to\0\0\0\x0c\xff\xff\xff\x18\0\0\0\x0c\0\0\0\0\0\0\x0c8\0\0\0\x01\0\0\0\x08\0\0\0\0\xff\xff\xff,\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x1c\xff\xff\xff\x04\0\0\0item\0\0\0\0\x10\0\0\0was_generated_by\0\0\0\0\x10\0\x14\0\x10\0\x0e\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x14\0\0\0\x0c\0\0\0\0\0\x01\x05\x0c\0\0\0\0\0\0\0l\xff\xff\xff\x0f\0\0\0partIDAttribute\0\xac\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\x9c\xff\xff\xff\x02\0\0\0id\0\0\xd0\xff\xff\xff\x14\0\0\0\x0c\0\0\0\0\0\0\x05\x0c\0\0\0\0\0\0\0\xc0\xff\xff\xff\x0e\0\0\0namespace_uuid\0\0\x10\0\x14\0\x10\0\0\0\x0f\0\x04\0\0\0\x08\0\x10\0\0\0\x18\0\0\0\x0c\0\0\0\0\0\0\x05\x10\0\0\0\0\0\0\0\x04\0\x04\0\x04\0\0\0\x0e\0\0\0namespace_name\0\0\0\0\0\0\0\0\0\0", flight_descriptor: Some( FlightDescriptor { r#type: Path, @@ -1327,7 +1357,15 @@ roles: String("entity-0"), String("entity-1"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-0"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1344,7 +1382,15 @@ roles: String("entity-1"), String("entity-2"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-1"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1361,7 +1407,15 @@ roles: String("entity-2"), String("entity-3"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-2"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1378,7 +1432,15 @@ roles: String("entity-3"), String("entity-4"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-3"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1395,7 +1457,15 @@ roles: String("entity-4"), String("entity-5"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-4"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1412,7 +1482,15 @@ roles: String("entity-5"), String("entity-6"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-5"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1429,7 +1507,15 @@ roles: String("entity-6"), String("entity-7"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-6"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, { @@ -1446,72 +1532,173 @@ roles: String("entity-7"), String("entity-8"), ], - "was_associated_with": Array [], + "was_associated_with": Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent-7"), + "role": String("ROLE_TYPE"), + }, + }, + ], "was_informed_by": Array [], }, ], [ { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-0"), + "agent": String("agent-0"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-0"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-0"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-1"), + "agent": String("agent-1"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-1"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-1"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-2"), + "agent": String("agent-2"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-2"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-2"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-3"), + "agent": String("agent-3"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-3"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-3"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-4"), + "agent": String("agent-4"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-4"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-4"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-5"), + "agent": String("agent-5"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-5"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-5"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-6"), + "agent": String("agent-6"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-6"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-6"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, { - "acted_on_behalf_of": Array [], + "acted_on_behalf_of": Array [ + Object { + "activity": String("activity-7"), + "agent": String("agent-7"), + "role": String("DELEGATED_CERTIFIER"), + }, + ], "id": String("ContractorAgent-7"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), - "was_attributed_to": Array [], + "was_attributed_to": Array [ + Object { + "entity": String("entity-7"), + "role": String("UNSPECIFIED_INTERACTION"), + }, + ], }, ], [ { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-0"), + "source": String("CertificateEntity-0"), + }, + ], "id": String("CertificateEntity-0"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1521,17 +1708,37 @@ roles: "role": String("CERTIFIER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-0"), + "source": String("CertificateEntity-0"), + }, + ], "was_generated_by": Array [ String("activity-0"), String("activity-1"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-0"), + "source": String("CertificateEntity-0"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-0"), + "source": String("CertificateEntity-0"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-1"), + "source": String("CertificateEntity-1"), + }, + ], "id": String("CertificateEntity-1"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1545,17 +1752,37 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-1"), + "source": String("CertificateEntity-1"), + }, + ], "was_generated_by": Array [ String("activity-1"), String("activity-2"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-1"), + "source": String("CertificateEntity-1"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-1"), + "source": String("CertificateEntity-1"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-2"), + "source": String("CertificateEntity-2"), + }, + ], "id": String("CertificateEntity-2"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1569,17 +1796,37 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-2"), + "source": String("CertificateEntity-2"), + }, + ], "was_generated_by": Array [ String("activity-2"), String("activity-3"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-2"), + "source": String("CertificateEntity-2"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-2"), + "source": String("CertificateEntity-2"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-3"), + "source": String("CertificateEntity-3"), + }, + ], "id": String("CertificateEntity-3"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1593,17 +1840,37 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-3"), + "source": String("CertificateEntity-3"), + }, + ], "was_generated_by": Array [ String("activity-3"), String("activity-4"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-3"), + "source": String("CertificateEntity-3"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-3"), + "source": String("CertificateEntity-3"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-4"), + "source": String("CertificateEntity-4"), + }, + ], "id": String("CertificateEntity-4"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1617,17 +1884,37 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-4"), + "source": String("CertificateEntity-4"), + }, + ], "was_generated_by": Array [ String("activity-4"), String("activity-5"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-4"), + "source": String("CertificateEntity-4"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-4"), + "source": String("CertificateEntity-4"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-5"), + "source": String("CertificateEntity-5"), + }, + ], "id": String("CertificateEntity-5"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1641,17 +1928,37 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-5"), + "source": String("CertificateEntity-5"), + }, + ], "was_generated_by": Array [ String("activity-5"), String("activity-6"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-5"), + "source": String("CertificateEntity-5"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-5"), + "source": String("CertificateEntity-5"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-6"), + "source": String("CertificateEntity-6"), + }, + ], "id": String("CertificateEntity-6"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1665,17 +1972,37 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-6"), + "source": String("CertificateEntity-6"), + }, + ], "was_generated_by": Array [ String("activity-6"), String("activity-7"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-6"), + "source": String("CertificateEntity-6"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-6"), + "source": String("CertificateEntity-6"), + }, + ], }, { "certIDAttribute": String("certIDAttribute-value"), - "had_primary_source": Array [], + "had_primary_source": Array [ + Object { + "activity": String("activity-ps-7"), + "source": String("CertificateEntity-7"), + }, + ], "id": String("CertificateEntity-7"), "namespace_name": String("default"), "namespace_uuid": String("00000000-0000-0000-0000-000000000000"), @@ -1689,13 +2016,28 @@ roles: "role": String("MANUFACTURER"), }, ], - "was_derived_from": Array [], + "was_derived_from": Array [ + Object { + "activity": String("activity-d-7"), + "source": String("CertificateEntity-7"), + }, + ], "was_generated_by": Array [ String("activity-7"), String("activity-8"), ], - "was_quoted_from": Array [], - "was_revision_of": Array [], + "was_quoted_from": Array [ + Object { + "activity": String("activity-q-7"), + "source": String("CertificateEntity-7"), + }, + ], + "was_revision_of": Array [ + Object { + "activity": String("activity-r-7"), + "source": String("CertificateEntity-7"), + }, + ], }, ], ] diff --git a/crates/chronicle-arrow/src/meta.rs b/crates/chronicle-arrow/src/meta.rs index 1f7a2469..70f66acd 100644 --- a/crates/chronicle-arrow/src/meta.rs +++ b/crates/chronicle-arrow/src/meta.rs @@ -40,20 +40,35 @@ pub fn attribution_struct() -> arrow_schema::DataType { pub fn derivation_struct() -> arrow_schema::DataType { arrow_schema::DataType::Struct( vec![ - arrow_schema::Field::new("target", arrow_schema::DataType::Utf8, false), + arrow_schema::Field::new("source", arrow_schema::DataType::Utf8, false), arrow_schema::Field::new("activity", arrow_schema::DataType::Utf8, false), ] .into(), ) } +pub fn qualified_agent_struct() -> arrow_schema::DataType { + arrow_schema::DataType::Struct( + vec![ + arrow_schema::Field::new("agent", arrow_schema::DataType::Utf8, false), + arrow_schema::Field::new("role", arrow_schema::DataType::Utf8, true), + ] + .into(), + ) +} + pub fn association_struct() -> arrow_schema::DataType { arrow_schema::DataType::Struct( vec![ - arrow_schema::Field::new("responsible_agent", arrow_schema::DataType::Utf8, false), - arrow_schema::Field::new("responsible_role", arrow_schema::DataType::Utf8, true), - arrow_schema::Field::new("delegate_agent", arrow_schema::DataType::Utf8, true), - arrow_schema::Field::new("delegate_role", arrow_schema::DataType::Utf8, true), + arrow_schema::Field::new("responsible", qualified_agent_struct(), false), + arrow_schema::Field::new( + "delegated", + arrow_schema::DataType::new_list( + qualified_agent_struct(), + true, // Set the List type as non-nullable + ), + false, + ), ] .into(), ) @@ -63,7 +78,7 @@ pub fn agent_delegation_struct() -> arrow_schema::DataType { arrow_schema::DataType::Struct( vec![ arrow_schema::Field::new("agent", arrow_schema::DataType::Utf8, false), - arrow_schema::Field::new("activity", arrow_schema::DataType::Utf8, true), + arrow_schema::Field::new("activity", arrow_schema::DataType::Utf8, false), arrow_schema::Field::new("role", arrow_schema::DataType::Utf8, true), ] .into(), @@ -164,13 +179,13 @@ pub fn schema_for_activity(activity: &ActivityDef) -> Schema { builder.push(arrow_schema::Field::new( "used", arrow_schema::DataType::new_list(arrow_schema::DataType::Utf8, false), - true, + false, )); builder.push(arrow_schema::Field::new( "generated", arrow_schema::DataType::new_list(arrow_schema::DataType::Utf8, false), - true, + false, )); builder.push(arrow_schema::Field::new( @@ -181,7 +196,7 @@ pub fn schema_for_activity(activity: &ActivityDef) -> Schema { builder.push(arrow_schema::Field::new( "was_associated_with", - arrow_schema::DataType::new_list(association_struct(), false), + arrow_schema::DataType::new_list(association_struct(), true), false, )); @@ -203,7 +218,7 @@ pub fn schema_for_agent(agent: &AgentDef) -> Schema { builder.push(arrow_schema::Field::new( "acted_on_behalf_of", arrow_schema::DataType::new_list(agent_delegation_struct(), false), - true, + false, )); builder.push(arrow_schema::Field::new( diff --git a/crates/chronicle-arrow/src/operations/activity.rs b/crates/chronicle-arrow/src/operations/activity.rs index bdce557b..f0061db9 100644 --- a/crates/chronicle-arrow/src/operations/activity.rs +++ b/crates/chronicle-arrow/src/operations/activity.rs @@ -1,16 +1,18 @@ use arrow_array::{Array, RecordBatch}; - use common::{ attributes::Attributes, prov::{ operations::{ChronicleOperation, SetAttributes}, - ActivityId, EntityId, NamespaceId, + ActivityId, AgentId, EntityId, NamespaceId, Role, }, }; use futures::StreamExt; -use crate::ChronicleArrowError; +use crate::{ + query::{ActivityAssociationRef, AgentInteraction}, + ChronicleArrowError, +}; use super::{string_list_column, with_implied}; @@ -72,6 +74,100 @@ fn get_ended( opt_time_column(record_batch, "ended", row_index) } +fn get_was_associated_with( + record_batch: &RecordBatch, + row_index: usize, +) -> Result, ChronicleArrowError> { + use arrow_array::{ListArray, StringArray, StructArray}; + + let column_index = record_batch + .schema() + .index_of("was_associated_with") + .map_err(|_| ChronicleArrowError::MissingColumn("was_associated_with".to_string()))?; + let column = record_batch.column(column_index); + let list_array = column + .as_any() + .downcast_ref::() + .ok_or(ChronicleArrowError::ColumnTypeMismatch("Expected ListArray".to_string()))?; + let binding = list_array.value(row_index); + let struct_array = binding + .as_any() + .downcast_ref::() + .ok_or(ChronicleArrowError::ColumnTypeMismatch("Expected StructArray".to_string()))?; + + let mut associations = Vec::new(); + for i in 0..struct_array.len() { + let responsible_struct_array = + struct_array.column(0).as_any().downcast_ref::().ok_or( + ChronicleArrowError::ColumnTypeMismatch( + "Expected StructArray for responsible".to_string(), + ), + )?; + + let agent_array = responsible_struct_array + .column(0) + .as_any() + .downcast_ref::() + .ok_or(ChronicleArrowError::ColumnTypeMismatch( + "Expected StringArray for agent".to_string(), + ))?; + let role_array = responsible_struct_array + .column(1) + .as_any() + .downcast_ref::() + .ok_or(ChronicleArrowError::ColumnTypeMismatch( + "Expected StringArray for role".to_string(), + ))?; + + let agent = agent_array.value(i).to_string(); + let role = Some(role_array.value(i).to_string()); + + // Handling the delegated field, which is a ListArray of StructArray + let delegated_list_array = + struct_array.column(1).as_any().downcast_ref::().ok_or( + ChronicleArrowError::ColumnTypeMismatch( + "Expected ListArray for delegated".to_string(), + ), + )?; + let delegated_binding = delegated_list_array.value(i); + let delegated_struct_array = delegated_binding + .as_any() + .downcast_ref::() + .ok_or(ChronicleArrowError::ColumnTypeMismatch( + "Expected StructArray for delegated".to_string(), + ))?; + + let mut delegated_agents = Vec::new(); + for j in 0..delegated_struct_array.len() { + let delegated_agent_array = + delegated_struct_array.column(0).as_any().downcast_ref::().ok_or( + ChronicleArrowError::ColumnTypeMismatch( + "Expected StringArray for delegated agent".to_string(), + ), + )?; + let delegated_role_array = + delegated_struct_array.column(1).as_any().downcast_ref::().ok_or( + ChronicleArrowError::ColumnTypeMismatch( + "Expected StringArray for delegated role".to_string(), + ), + )?; + + let delegated_agent = delegated_agent_array.value(j).to_string(); + let delegated_role = Some(delegated_role_array.value(j).to_string()); + + delegated_agents + .push(AgentInteraction { agent: delegated_agent, role: delegated_role }); + } + + associations.push(ActivityAssociationRef { + responsible: AgentInteraction { agent, role }, + delegated: delegated_agents, + }); + } + + Ok(associations) +} + pub fn activity_operations( ns: &NamespaceId, id: &str, @@ -138,5 +234,26 @@ pub fn activity_operations( )); } + let was_associated_with_refs = get_was_associated_with(record_batch, row_index)?; + + for association_ref in was_associated_with_refs { + operations.push(ChronicleOperation::was_associated_with( + ns.clone(), + ActivityId::from_external_id(id), + AgentId::from_external_id(&association_ref.responsible.agent), + association_ref.responsible.role.map(Role), + )); + + for delegated in &association_ref.delegated { + operations.push(ChronicleOperation::agent_acts_on_behalf_of( + ns.clone(), + AgentId::from_external_id(id), + AgentId::from_external_id(&association_ref.responsible.agent), + Some(ActivityId::from_external_id(id)), + delegated.role.as_ref().map(|role| Role(role.clone())), + )); + } + } + Ok(with_implied(operations)) } diff --git a/crates/chronicle-arrow/src/operations/agent.rs b/crates/chronicle-arrow/src/operations/agent.rs index 55ea0d41..d93b5b3e 100644 --- a/crates/chronicle-arrow/src/operations/agent.rs +++ b/crates/chronicle-arrow/src/operations/agent.rs @@ -39,11 +39,11 @@ fn get_acted_on_behalf_of( "acted_on_behalf_of", row_index, "agent", - "role", "activity", + "role", )? .into_iter() - .map(|(agent, role, activity)| ActedOnBehalfOfRef { agent, role, activity }) + .map(|(agent, activity, role)| ActedOnBehalfOfRef { agent, role, activity }) .collect()) } @@ -81,7 +81,7 @@ pub fn agent_operations( ns.clone(), AgentId::from_external_id(id), AgentId::from_external_id(acted_on_behalf_of_ref.agent), - acted_on_behalf_of_ref.activity.map(ActivityId::from_external_id), + Some(ActivityId::from_external_id(acted_on_behalf_of_ref.activity)), acted_on_behalf_of_ref.role.map(Role::from), )); } diff --git a/crates/chronicle-arrow/src/operations/entity.rs b/crates/chronicle-arrow/src/operations/entity.rs index dc05c32a..cbb59cf0 100644 --- a/crates/chronicle-arrow/src/operations/entity.rs +++ b/crates/chronicle-arrow/src/operations/entity.rs @@ -44,9 +44,9 @@ fn get_derivation( record_batch: &RecordBatch, row_index: usize, ) -> Result, ChronicleArrowError> { - Ok(struct_2_list_column(record_batch, column_name, row_index, "target", "activity")? + Ok(struct_2_list_column(record_batch, column_name, row_index, "source", "activity")? .into_iter() - .map(|(target, activity)| DerivationRef { target, activity }) + .map(|(target, activity)| DerivationRef { source: target, activity }) .collect()) } @@ -92,8 +92,8 @@ pub fn entity_operations( for was_derived_from_ref in was_derived_from_refs { operations.push(ChronicleOperation::entity_derive( ns.clone(), + EntityId::from_external_id(was_derived_from_ref.source), EntityId::from_external_id(id), - EntityId::from_external_id(was_derived_from_ref.target), Some(ActivityId::from_external_id(was_derived_from_ref.activity)), DerivationType::None, )) @@ -104,8 +104,8 @@ pub fn entity_operations( for had_primary_source_ref in had_primary_source_refs { operations.push(ChronicleOperation::entity_derive( ns.clone(), + EntityId::from_external_id(had_primary_source_ref.source), EntityId::from_external_id(id), - EntityId::from_external_id(had_primary_source_ref.target), Some(ActivityId::from_external_id(had_primary_source_ref.activity)), DerivationType::PrimarySource, )) @@ -116,8 +116,8 @@ pub fn entity_operations( for was_quoted_from_ref in was_quoted_from_refs { operations.push(ChronicleOperation::entity_derive( ns.clone(), + EntityId::from_external_id(was_quoted_from_ref.source), EntityId::from_external_id(id), - EntityId::from_external_id(was_quoted_from_ref.target), Some(ActivityId::from_external_id(was_quoted_from_ref.activity)), DerivationType::Quotation, )) @@ -128,8 +128,8 @@ pub fn entity_operations( for was_revision_of_ref in was_revision_of_refs { operations.push(ChronicleOperation::entity_derive( ns.clone(), + EntityId::from_external_id(was_revision_of_ref.source), EntityId::from_external_id(id), - EntityId::from_external_id(was_revision_of_ref.target), Some(ActivityId::from_external_id(was_revision_of_ref.activity)), DerivationType::Revision, )) diff --git a/crates/chronicle-arrow/src/operations/mod.rs b/crates/chronicle-arrow/src/operations/mod.rs index aa03c5de..eef1fcdc 100644 --- a/crates/chronicle-arrow/src/operations/mod.rs +++ b/crates/chronicle-arrow/src/operations/mod.rs @@ -23,8 +23,6 @@ use common::{ prov::{operations::ChronicleOperation, NamespaceId}, }; -use futures::StreamExt; - use uuid::Uuid; use crate::{ @@ -99,12 +97,12 @@ pub fn batch_to_flight_data( async fn create_chronicle_namespace( record_batch: &RecordBatch, - api: &ApiDispatch, + _api: &ApiDispatch, ) -> Result<(), ChronicleArrowError> { - let uuid = record_batch + let _uuid = record_batch .column_by_name("uuid") .ok_or(ChronicleArrowError::MissingColumn("uuid".to_string()))?; - let name = record_batch + let _name = record_batch .column_by_name("name") .ok_or(ChronicleArrowError::MissingColumn("name".to_string()))?; @@ -305,7 +303,7 @@ fn struct_3_list_column_opt_string( field1_name: &str, field2_name: &str, field3_name: &str, -) -> Result, Option)>, ChronicleArrowError> { +) -> Result)>, ChronicleArrowError> { let column_index = record_batch .schema() .index_of(column_name) @@ -329,18 +327,21 @@ fn struct_3_list_column_opt_string( .as_any() .downcast_ref::() .ok_or_else(|| ChronicleArrowError::ColumnTypeMismatch(field1_name.to_string()))?; - let field2_array = field2_index.as_any().downcast_ref::(); + let field2_array = field2_index + .as_any() + .downcast_ref::() + .ok_or_else(|| ChronicleArrowError::ColumnTypeMismatch(field2_name.to_string()))?; let field3_array = field3_index.as_any().downcast_ref::(); Ok((0..struct_array.len()) .map(|i| { ( field1_array.value(i).to_string(), - field2_array.map(|arr| arr.value(i).to_string()), + field2_array.value(i).to_string(), field3_array.map(|arr| arr.value(i).to_string()), ) }) - .collect::, Option)>>()) + .collect::)>>()) } else { Ok(vec![]) } diff --git a/crates/chronicle-arrow/src/peekablestream.rs b/crates/chronicle-arrow/src/peekablestream.rs index 3045df5f..4e8860b5 100644 --- a/crates/chronicle-arrow/src/peekablestream.rs +++ b/crates/chronicle-arrow/src/peekablestream.rs @@ -4,50 +4,6 @@ use arrow_flight::FlightData; use futures::{stream::Peekable, Stream, StreamExt}; use tonic::{Status, Streaming}; -/// A wrapper around [`Streaming`] that allows "peeking" at the -/// message at the front of the stream without consuming it. -/// This is needed because sometimes the first message in the stream will contain -/// a [`FlightDescriptor`] in addition to potentially any data, and the dispatch logic -/// must inspect this information. -/// -/// # Example -/// -/// [`PeekableFlightDataStream::peek`] can be used to peek at the first message without -/// discarding it; otherwise, `PeekableFlightDataStream` can be used as a regular stream. -/// See the following example: -/// -/// ```no_run -/// use arrow_array::RecordBatch; -/// use arrow_flight::decode::FlightRecordBatchStream; -/// use arrow_flight::FlightDescriptor; -/// use arrow_flight::error::FlightError; -/// use PeekableFlightDataStream; -/// use tonic::{Request, Status}; -/// use futures::TryStreamExt; -/// -/// #[tokio::main] -/// async fn main() -> Result<(), Status> { -/// let request: Request = todo!(); -/// let stream: PeekableFlightDataStream = request.into_inner(); -/// -/// // The first message contains the flight descriptor and the schema. -/// // Read the flight descriptor without discarding the schema: -/// let flight_descriptor: FlightDescriptor = stream -/// .peek() -/// .await -/// .cloned() -/// .transpose()? -/// .and_then(|data| data.flight_descriptor) -/// .expect("first message should contain flight descriptor"); -/// -/// // Pass the stream through a decoder -/// let batches: Vec = FlightRecordBatchStream::new_from_flight_data( -/// request.into_inner().map_err(|e| e.into()), -/// ) -/// .try_collect() -/// .await?; -/// } -/// ``` pub struct PeekableFlightDataStream { inner: Peekable>, } diff --git a/crates/chronicle-arrow/src/query/activity.rs b/crates/chronicle-arrow/src/query/activity.rs index 7800117c..a978201b 100644 --- a/crates/chronicle-arrow/src/query/activity.rs +++ b/crates/chronicle-arrow/src/query/activity.rs @@ -1,16 +1,18 @@ use std::{collections::HashMap, sync::Arc}; -use crate::{meta::association_struct, ChronicleArrowError, DomainTypeMeta}; -use arrow::array::{ArrayBuilder, StringBuilder, StructBuilder}; +use crate::{ChronicleArrowError, DomainTypeMeta}; +use arrow::array::{ArrayBuilder, ListBuilder, StringBuilder, StructBuilder}; use arrow_array::{ Array, BooleanArray, Int64Array, ListArray, RecordBatch, StringArray, TimestampNanosecondArray, }; -use arrow_buffer::{Buffer, ToByteSlice}; -use arrow_data::ArrayData; + use arrow_schema::{DataType, Field}; use chronicle_persistence::{ - query::{Activity, Generation, Namespace, Usage, WasInformedBy}, - schema::{activity, entity, generation, namespace, usage, wasinformedby}, + query::{Activity, Association, Delegation, Generation, Namespace, Usage, WasInformedBy}, + schema::{ + activity, agent, association, delegation, entity, generation, namespace, usage, + wasinformedby, + }, }; use chrono::{DateTime, Utc}; use common::{ @@ -40,12 +42,16 @@ pub fn activity_count_by_type( Ok(count) } +#[derive(Default)] +pub struct AgentInteraction { + pub(crate) agent: String, + pub(crate) role: Option, +} + #[derive(Default)] pub struct ActivityAssociationRef { - pub(crate) responsible_agent: String, - pub(crate) responsible_role: Option, - pub(crate) delegate_agent: Option, - pub(crate) delegate_role: Option, + pub(crate) responsible: AgentInteraction, + pub(crate) delegated: Vec, } #[derive(Default)] @@ -206,86 +212,74 @@ impl ActivityAndReferences { fn associations_to_list_array( associations: Vec>, ) -> Result { - let offsets: Vec = std::iter::once(0) - .chain(associations.iter().map(|v| v.len() as i32)) - .scan(0, |state, len| { - *state += len; - Some(*state) - }) - .collect(); - - let fields = vec![ - Field::new("responsible_agent", DataType::Utf8, false), - Field::new("responsible_role", DataType::Utf8, true), - Field::new("delegate_agent", DataType::Utf8, true), - Field::new("delegate_role", DataType::Utf8, true), - ]; - let field_builders = vec![ - Box::new(StringBuilder::new()) as Box, - Box::new(StringBuilder::new()) as Box, - Box::new(StringBuilder::new()) as Box, - Box::new(StringBuilder::new()) as Box, - ]; - - let mut builder = StructBuilder::new(fields, field_builders); - - for association in associations.into_iter().flatten() { - builder - .field_builder::(0) - .expect("Failed to get field builder for responsible_agent") - .append_value(&association.responsible_agent); - if let Some(role) = &association.responsible_role { - builder - .field_builder::(1) - .expect("Failed to get field builder for responsible_role") - .append_value(role); - } else { - builder - .field_builder::(1) - .expect("Failed to get field builder for responsible_role") - .append_null(); - } - if let Some(agent) = &association.delegate_agent { - builder - .field_builder::(2) - .expect("Failed to get field builder for delegate_agent") - .append_value(agent); - } else { - builder - .field_builder::(2) - .expect("Failed to get field builder for delegate_agent") - .append_null(); - } - if let Some(role) = &association.delegate_role { - builder - .field_builder::(3) - .expect("Failed to get field builder for delegate_role") - .append_value(role); - } else { - builder - .field_builder::(3) - .expect("Failed to get field builder for delegate_role") - .append_null(); + let fields = + vec![Field::new("agent", DataType::Utf8, false), Field::new("role", DataType::Utf8, true)]; + + let agent_struct = DataType::Struct(fields.clone().into()); + + let mut builder = ListBuilder::new(StructBuilder::new( + vec![ + Field::new("responsible", agent_struct.clone(), false), + Field::new( + "delegated", + DataType::List(Arc::new(Field::new("item", agent_struct, true))), + false, + ), + ], + vec![ + Box::new(StructBuilder::from_fields(fields.clone(), 0)), + Box::new(ListBuilder::new(StructBuilder::from_fields(fields, 0))), + ], + )); + + for association_vec in associations { + let struct_builder = builder.values(); + + for association in association_vec { + // Build the responsible field + let responsible_builder = struct_builder.field_builder::(0).unwrap(); + responsible_builder + .field_builder::(0) + .unwrap() + .append_value(&association.responsible.agent); + if let Some(role) = &association.responsible.role { + responsible_builder + .field_builder::(1) + .unwrap() + .append_value(role); + } else { + responsible_builder.field_builder::(1).unwrap().append_null(); + } + responsible_builder.append(true); + + // Build the delegated field + let delegated_builder = + struct_builder.field_builder::>(1).unwrap(); + for agent_interaction in &association.delegated { + let interaction_builder = delegated_builder.values(); + interaction_builder + .field_builder::(0) + .unwrap() + .append_value(&agent_interaction.agent); + if let Some(role) = &agent_interaction.role { + interaction_builder + .field_builder::(1) + .unwrap() + .append_value(role); + } else { + interaction_builder.field_builder::(1).unwrap().append_null(); + } + interaction_builder.append(true); + } + delegated_builder.append(true); + + struct_builder.append(true); } builder.append(true); } - let values_array = builder.finish(); - - let data_type = DataType::new_list(association_struct(), false); - let offsets_buffer = Buffer::from(offsets.to_byte_slice()); - - let list_array = ListArray::from( - ArrayData::builder(data_type.clone()) - .add_child_data(values_array.to_data()) - .len(offsets.len() - 1) - .null_count(0) - .add_buffer(offsets_buffer) - .build()?, - ); - - Ok(list_array) + Ok(builder.finish()) } pub fn load_activities_by_type( @@ -349,6 +343,69 @@ pub fn load_activities_by_type( acc }); + let associations_map: HashMap> = + Association::belonging_to(&activities) + .inner_join(agent::table.on(association::agent_id.eq(agent::id))) + .select((association::activity_id, (agent::id, agent::external_id, association::role))) + .load::<(i32, (i32, String, String))>(&mut connection)? + .into_iter() + .fold( + HashMap::new(), + |mut acc: HashMap>, + (activity_id, (agent_id, agent_external_id, role_external_id))| { + acc.entry(activity_id) + .or_default() + .insert(agent_id, (agent_external_id, role_external_id)); + acc + }, + ); + + let delegations_map: HashMap> = + Delegation::belonging_to(&activities) + .inner_join(agent::table.on(delegation::delegate_id.eq(agent::id))) + .select(( + delegation::activity_id, + (delegation::responsible_id, agent::external_id, delegation::role), + )) + .load::<(i32, (i32, String, String))>(&mut connection)? + .into_iter() + .fold( + HashMap::new(), + |mut acc: HashMap>, + (activity_id, (agent_id, agent_external_id, role_external_id))| { + acc.entry(activity_id) + .or_default() + .insert(agent_id, (agent_external_id, role_external_id)); + acc + }, + ); + + let mut activity_associations: HashMap> = HashMap::new(); + + for (activity_id, agent_map) in associations_map.into_iter() { + let mut association_refs = Vec::new(); + for (agent_id, (agent_external_id, role_external_id)) in agent_map.into_iter() { + let mut delegated_agents = Vec::new(); + if let Some(delegations) = delegations_map.get(&activity_id) { + if let Some((delegated_agent_external_id, delegated_role_external_id)) = + delegations.get(&agent_id) + { + delegated_agents.push(AgentInteraction { + agent: delegated_agent_external_id.clone(), + role: Some(delegated_role_external_id.clone()), + }); + } + } + association_refs.push(ActivityAssociationRef { + responsible: AgentInteraction { + agent: agent_external_id, + role: Some(role_external_id), + }, + delegated: delegated_agents, + }); + } + activity_associations.insert(activity_id, association_refs); + } let fetched_records = activities.len() as u64; let mut activities_and_references = vec![]; @@ -367,8 +424,120 @@ pub fn load_activities_by_type( was_informed_by: was_informed_by_map.remove(&activity.id).unwrap_or_default(), used: used_map.remove(&activity.id).unwrap_or_default(), generated: generated_map.remove(&activity.id).unwrap_or_default(), - ..Default::default() + was_associated_with: activity_associations.remove(&activity.id).unwrap_or_default(), }); } Ok((activities_and_references.into_iter(), fetched_records, fetched_records)) } + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_associations_to_list_array_empty() { + let associations = Vec::new(); + let result = associations_to_list_array(associations); + assert!(result.is_ok()); + let array = result.unwrap(); + assert_eq!(array.len(), 0); + } + + #[test] + fn test_associations_to_list_array_single() { + let associations = vec![ActivityAssociationRef { + responsible: AgentInteraction { + agent: "agent1".to_string(), + role: Some("role1".to_string()), + }, + delegated: vec![AgentInteraction { + agent: "delegated1".to_string(), + role: Some("role3".to_string()), + }], + }]; + let result = associations_to_list_array(vec![associations]).unwrap(); + + let json = arrow::json::writer::array_to_json_array(&result).unwrap(); + + insta::assert_debug_snapshot!(&json, @r###" + [ + Array [ + Object { + "delegated": Array [ + Object { + "agent": String("delegated1"), + "role": String("role3"), + }, + ], + "responsible": Object { + "agent": String("agent1"), + "role": String("role1"), + }, + }, + ], + ] + "### ); + } + + #[test] + fn test_associations_to_list_array_multiple() { + let associations = vec![ + ActivityAssociationRef { + responsible: AgentInteraction { + agent: "agent1".to_string(), + role: Some("role1".to_string()), + }, + delegated: vec![], + }, + ActivityAssociationRef { + responsible: AgentInteraction { + agent: "agent2".to_string(), + role: Some("role2".to_string()), + }, + delegated: vec![ + AgentInteraction { + agent: "delegated1".to_string(), + role: Some("role3".to_string()), + }, + AgentInteraction { + agent: "delegated2".to_string(), + role: Some("role3".to_string()), + }, + ], + }, + ]; + let result = associations_to_list_array(vec![associations]).unwrap(); + + let json = arrow::json::writer::array_to_json_array(&result).unwrap(); + + insta::assert_debug_snapshot!(&json, @r###" + [ + Array [ + Object { + "delegated": Array [], + "responsible": Object { + "agent": String("agent1"), + "role": String("role1"), + }, + }, + Object { + "delegated": Array [ + Object { + "agent": String("delegated1"), + "role": String("role3"), + }, + Object { + "agent": String("delegated2"), + "role": String("role3"), + }, + ], + "responsible": Object { + "agent": String("agent2"), + "role": String("role2"), + }, + }, + ], + ] + "### ); + } +} diff --git a/crates/chronicle-arrow/src/query/agent.rs b/crates/chronicle-arrow/src/query/agent.rs index 6a478a56..e38c47a0 100644 --- a/crates/chronicle-arrow/src/query/agent.rs +++ b/crates/chronicle-arrow/src/query/agent.rs @@ -10,13 +10,13 @@ use arrow_buffer::{Buffer, ToByteSlice}; use arrow_data::ArrayData; use arrow_schema::{DataType, Field}; use chronicle_persistence::{ - query::{Agent, Namespace}, - schema::{agent, namespace}, + query::{Agent, Attribution, Delegation, Namespace}, + schema::{activity, agent, attribution, delegation, entity, namespace}, }; use common::{ attributes::Attributes, domain::PrimitiveType, - prov::{DomaintypeId, ExternalIdPart}, + prov::{DomaintypeId, ExternalIdPart, Role}, }; use diesel::{ pg::PgConnection, @@ -41,7 +41,7 @@ pub fn agent_count_by_type( pub struct ActedOnBehalfOfRef { pub(crate) agent: String, pub(crate) role: Option, - pub(crate) activity: Option, + pub(crate) activity: String, } #[derive(Default)] @@ -167,6 +167,7 @@ impl AgentAndReferences { RecordBatch::try_new(meta.schema.clone(), columns).map_err(ChronicleArrowError::from) } } + fn agent_acted_on_behalf_of_to_list_array( agent_attributions: Vec>, ) -> Result { @@ -184,7 +185,7 @@ fn agent_acted_on_behalf_of_to_list_array( let fields = vec![ Field::new("agent", DataType::Utf8, false), - Field::new("activity", DataType::Utf8, true), + Field::new("activity", DataType::Utf8, false), Field::new("role", DataType::Utf8, true), ]; let field_builders = vec![ @@ -203,7 +204,7 @@ fn agent_acted_on_behalf_of_to_list_array( builder .field_builder::(1) .expect("Failed to get activity field builder") - .append_option(acted_on_behalf_of.activity.as_deref()); + .append_value(acted_on_behalf_of.activity); builder .field_builder::(2) .expect("Failed to get role field builder") @@ -315,6 +316,47 @@ pub fn load_agents_by_type( let (agents, namespaces): (Vec, Vec) = agents_and_namespaces.into_iter().unzip(); + let mut attributions_map: HashMap> = + Attribution::belonging_to(&agents) + .inner_join(entity::table.on(attribution::entity_id.eq(entity::id))) + .select((attribution::agent_id, attribution::role, entity::external_id)) + .load::<(i32, Role, String)>(&mut connection)? + .into_iter() + .fold( + HashMap::new(), + |mut acc: HashMap>, (id, role, external_id)| { + acc.entry(id).or_default().push(AgentAttributionRef { + entity: external_id, + role: Some(role.to_string()), + }); + acc + }, + ); + + let mut delegations_map: HashMap> = + Delegation::belonging_to(&agents) + .inner_join(activity::table.on(delegation::activity_id.eq(activity::id))) + .inner_join(agent::table.on(delegation::delegate_id.eq(agent::id))) + .select(( + delegation::responsible_id, + delegation::role, + activity::external_id, + agent::external_id, + )) + .load::<(i32, Role, String, String)>(&mut connection)? + .into_iter() + .fold( + HashMap::new(), + |mut acc: HashMap>, (id, role, activity, delegate)| { + acc.entry(id).or_default().push(ActedOnBehalfOfRef { + agent: delegate, + activity, + role: Some(role.to_string()), + }); + acc + }, + ); + let mut agents_and_references = vec![]; for (agent, ns) in agents.into_iter().zip(namespaces) { @@ -325,8 +367,9 @@ pub fn load_agents_by_type( attributes: Attributes::new( agent.domaintype.map(DomaintypeId::from_external_id), vec![], - ), // Placeholder for attribute loading logic - ..Default::default() + ), + was_attributed_to: attributions_map.remove(&agent.id).unwrap_or_default(), + acted_on_behalf_of: delegations_map.remove(&agent.id).unwrap_or_default(), }); } diff --git a/crates/chronicle-arrow/src/query/entity.rs b/crates/chronicle-arrow/src/query/entity.rs index 7c612e8e..8dfd0a2a 100644 --- a/crates/chronicle-arrow/src/query/entity.rs +++ b/crates/chronicle-arrow/src/query/entity.rs @@ -67,7 +67,7 @@ pub fn entity_count_by_type( #[derive(Default, Debug)] pub struct DerivationRef { - pub target: String, + pub source: String, pub activity: String, } @@ -237,7 +237,7 @@ fn derivations_to_list_array( .collect(); let fields = vec![ - Field::new("target", DataType::Utf8, false), + Field::new("source", DataType::Utf8, false), Field::new("activity", DataType::Utf8, false), ]; let field_builders = vec![ @@ -251,7 +251,7 @@ fn derivations_to_list_array( builder .field_builder::(0) .unwrap() - .append_value(derivation.target); + .append_value(derivation.source); builder .field_builder::(1) .unwrap() @@ -439,7 +439,7 @@ pub fn load_entities_by_type( (entity_id, activity_external_id, entity_external_id, derivation_type)| { acc.entry((entity_id, derivation_type)).or_default().push(DerivationRef { activity: activity_external_id, - target: entity_external_id, + source: entity_external_id, }); acc }, diff --git a/crates/chronicle-arrow/src/query/mod.rs b/crates/chronicle-arrow/src/query/mod.rs index a8e9d10a..d7d17002 100644 --- a/crates/chronicle-arrow/src/query/mod.rs +++ b/crates/chronicle-arrow/src/query/mod.rs @@ -13,13 +13,6 @@ use arrow_buffer::{Buffer, ToByteSlice}; use arrow_data::ArrayData; use arrow_schema::DataType; -use common::prov::DomaintypeId; -use diesel::{ - pg::PgConnection, - r2d2::{ConnectionManager, Pool}, -}; - - // For simple id only relations, we can just reuse this mapping fn vec_vec_string_to_list_array( vec_vec_string: Vec>, diff --git a/crates/chronicle-domain-test/src/test.rs b/crates/chronicle-domain-test/src/test.rs index e986a565..86bcf758 100644 --- a/crates/chronicle-domain-test/src/test.rs +++ b/crates/chronicle-domain-test/src/test.rs @@ -65,8 +65,8 @@ pub async fn main() { mod test { use chronicle::{ api::{ - chronicle_graphql::{OpaCheck, Store, Subscription}, - Api, UuidGen, + chronicle_graphql::{construct_schema, OpaCheck, Subscription}, + Api, Store, UuidGen, }, async_graphql::{Request, Response, Schema}, bootstrap::opa::CliPolicyLoader, @@ -78,7 +78,6 @@ mod test { CHRONICLE_NAMESPACE, }; use chronicle_test_infrastructure::substitutes::{embed_substrate, TemporaryDatabase}; - use common::identity::AuthId; use uuid::Uuid; @@ -152,15 +151,10 @@ mod test { .await .unwrap(); - let schema = Schema::build(Query, Mutation, Subscription) - .extension(OpaCheck { claim_parser: None }) - .data(Store::new(pool)) - .data(dispatch) - .data(AuthId::chronicle()) - .data(opa_executor) - .finish(); + let schema = + construct_schema(Query, Mutation, Subscription, None, &pool, &dispatch, opa_executor); - (schema, database) + (schema.unwrap(), database) } #[tokio::test] @@ -1391,8 +1385,6 @@ mod test { async fn agent_delegation_for_activity() { let (schema, _database) = test_schema().await; - // create contractors - insta::assert_toml_snapshot!(schema .execute(Request::new( r#" @@ -1851,16 +1843,16 @@ mod test { "#, )) .await, @r###" - [data.entityById] - id = 'chronicle:entity:testentity1' - externalId = 'testentity1' + [data.entityById] + id = 'chronicle:entity:testentity1' + externalId = 'testentity1' - [[data.entityById.wasDerivedFrom]] - id = 'chronicle:entity:testentity2' + [[data.entityById.wasDerivedFrom]] + id = 'chronicle:entity:testentity2' - [[data.entityById.hadPrimarySource]] - id = 'chronicle:entity:testentity2' - "###); + [[data.entityById.hadPrimarySource]] + id = 'chronicle:entity:testentity2' + "###); } #[tokio::test] @@ -1909,16 +1901,16 @@ mod test { "#, )) .await, @r###" - [data.entityById] - id = 'chronicle:entity:testentity1' - externalId = 'testentity1' + [data.entityById] + id = 'chronicle:entity:testentity1' + externalId = 'testentity1' - [[data.entityById.wasDerivedFrom]] - id = 'chronicle:entity:testentity2' + [[data.entityById.wasDerivedFrom]] + id = 'chronicle:entity:testentity2' - [[data.entityById.wasRevisionOf]] - id = 'chronicle:entity:testentity2' - "###); + [[data.entityById.wasRevisionOf]] + id = 'chronicle:entity:testentity2' + "###); } #[tokio::test] diff --git a/crates/chronicle-persistence/src/lib.rs b/crates/chronicle-persistence/src/lib.rs index 80cdb3a7..60bb33e9 100644 --- a/crates/chronicle-persistence/src/lib.rs +++ b/crates/chronicle-persistence/src/lib.rs @@ -10,7 +10,6 @@ use common::{ ProvModel, Role, Usage, }, }; -use derivative::*; use diesel::{ prelude::*, @@ -113,10 +112,8 @@ pub struct ConnectionOptions { pub busy_timeout: Option, } -#[derive(Derivative)] -#[derivative(Debug, Clone)] +#[derive(Clone)] pub struct Store { - #[derivative(Debug = "ignore")] pool: Pool>, } @@ -454,7 +451,7 @@ impl Store { Ok(()) } - #[instrument(skip(connection))] + #[instrument(skip_all)] fn apply_used( &self, connection: &mut PgConnection, @@ -485,7 +482,7 @@ impl Store { Ok(()) } - #[instrument(skip(connection))] + #[instrument(skip_all)] fn apply_was_informed_by( &self, connection: &mut PgConnection, @@ -644,7 +641,7 @@ impl Store { Ok(()) } - #[instrument(skip(connection))] + #[instrument(skip_all)] fn apply_was_generated_by( &self, connection: &mut PgConnection, @@ -714,7 +711,7 @@ impl Store { self.pool.get().map_err(StoreError::DbPool) } - #[instrument(skip(connection))] + #[instrument(skip_all)] pub fn get_current_agent( &self, connection: &mut PgConnection, @@ -726,7 +723,7 @@ impl Store { } /// Get the last fully synchronized offset - #[instrument] + #[instrument(skip_all)] pub fn get_last_block_id(&self) -> Result, StoreError> { use schema::ledgersync::dsl; self.connection()?.build_transaction().run(|connection| { @@ -744,7 +741,7 @@ impl Store { }) } - #[instrument(skip(connection))] + #[instrument(skip_all)] pub fn namespace_by_external_id( &self, connection: &mut PgConnection, @@ -762,12 +759,12 @@ impl Store { Ok((NamespaceId::from_external_id(ns.1, Uuid::from_str(&ns.2)?), ns.0)) } - #[instrument] + #[instrument(skip_all)] pub fn new(pool: Pool>) -> Result { Ok(Store { pool }) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_agent( &self, agent: query::Agent, @@ -842,7 +839,7 @@ impl Store { Ok(()) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_activity( &self, activity: query::Activity, @@ -935,7 +932,7 @@ impl Store { Ok(()) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_entity( &self, entity: query::Entity, @@ -1031,7 +1028,7 @@ impl Store { Ok(()) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_namespace( &self, connection: &mut PgConnection, @@ -1069,7 +1066,7 @@ impl Store { } /// Set the last fully synchronized offset - #[instrument(level = "info")] + #[instrument(skip(self),level = "info")] pub fn set_last_block_id( &self, block_id: &BlockId, @@ -1092,7 +1089,7 @@ impl Store { })?) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn use_agent( &self, connection: &mut PgConnection, @@ -1116,7 +1113,7 @@ impl Store { Ok(()) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_agent_id( &self, connection: &mut PgConnection, @@ -1137,7 +1134,7 @@ impl Store { Ok(model) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn apply_prov_model_for_agent_id( &self, connection: &mut PgConnection, @@ -1159,7 +1156,7 @@ impl Store { Ok(model) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_activity_id( &self, connection: &mut PgConnection, @@ -1180,7 +1177,7 @@ impl Store { Ok(model) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn apply_prov_model_for_activity_id( &self, connection: &mut PgConnection, @@ -1202,7 +1199,7 @@ impl Store { Ok(model) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_entity_id( &self, connection: &mut PgConnection, @@ -1223,7 +1220,7 @@ impl Store { Ok(model) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn apply_prov_model_for_entity_id( &self, connection: &mut PgConnection, @@ -1245,7 +1242,7 @@ impl Store { Ok(model) } - #[instrument(level = "trace", skip(connection))] +#[instrument(skip_all)] pub fn prov_model_for_usage( &self, connection: &mut PgConnection, diff --git a/crates/chronicle-persistence/src/query.rs b/crates/chronicle-persistence/src/query.rs index 3c150e91..0fd03fe5 100644 --- a/crates/chronicle-persistence/src/query.rs +++ b/crates/chronicle-persistence/src/query.rs @@ -134,10 +134,11 @@ pub struct Usage { entity_id: i32, } -#[derive(Debug, Queryable, Selectable, Associations, PartialEq)] +#[derive(Debug, Queryable, Selectable, Identifiable, Associations, PartialEq)] #[diesel(table_name = association)] #[diesel(belongs_to(Agent))] #[diesel(belongs_to(Activity))] +#[diesel(primary_key(agent_id, activity_id, role))] pub struct Association { agent_id: i32, activity_id: i32, @@ -155,10 +156,11 @@ pub struct Attribution { role: String, } -#[derive(Debug, Queryable, Selectable, Associations, PartialEq)] +#[derive(Debug, Queryable, Selectable, Associations, Identifiable, PartialEq)] #[diesel(table_name = delegation)] #[diesel(belongs_to(Agent, foreign_key = delegate_id, foreign_key = responsible_id))] #[diesel(belongs_to(Activity))] +#[diesel(primary_key(delegate_id, responsible_id, activity_id, role))] pub struct Delegation { delegate_id: i32, responsible_id: i32, diff --git a/crates/chronicle-synth/src/domain.rs b/crates/chronicle-synth/src/domain.rs index f369b752..04a379df 100644 --- a/crates/chronicle-synth/src/domain.rs +++ b/crates/chronicle-synth/src/domain.rs @@ -49,7 +49,7 @@ impl TypesAttributesRoles { Ok(domain) } } - #[allow(non_local_definitions)] + impl From for TypesAttributesRoles { fn from(value: ChronicleDomain) -> Self { let mut attribute_types = BTreeMap::new(); diff --git a/crates/chronicle-test-infrastructure/src/api_test.rs b/crates/chronicle-test-infrastructure/src/api_test.rs index d44a5b9a..c0b325ad 100644 --- a/crates/chronicle-test-infrastructure/src/api_test.rs +++ b/crates/chronicle-test-infrastructure/src/api_test.rs @@ -158,25 +158,22 @@ async fn test_import_operations() { .await .unwrap() .unwrap() - .1, @r###" - [ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 - ] + .0, @r###" + { + "namespaces": {}, + "agents": {}, + "acted_on_behalf_of": {}, + "delegation": {}, + "entities": {}, + "derivation": {}, + "generation": {}, + "attribution": {}, + "activities": {}, + "was_informed_by": {}, + "generated": {}, + "association": {}, + "usage": {} + } "###); } @@ -198,13 +195,10 @@ async fn create_namespace() { .compact_stable_order() .await .unwrap(), @r###" - { - "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - "###); + { + "@context": "http://chronicle.works/chr/1.0/c.jsonld" + } + "###); } #[tokio::test] @@ -238,25 +232,16 @@ async fn create_agent() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); } @@ -337,25 +322,16 @@ async fn create_activity() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:activity:testactivity", - "@type": [ - "prov:Activity", - "chronicle:domaintype:test" - ], - "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:activity:testactivity", + "@type": [ + "prov:Activity", + "chronicle:domaintype:test" + ], + "externalId": "testactivity", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); } @@ -392,25 +368,16 @@ async fn start_activity() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -446,7 +413,7 @@ async fn start_activity() { "@id": "chronicle:activity:testactivity", "@type": "prov:Activity", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -460,7 +427,7 @@ async fn start_activity() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -502,25 +469,16 @@ async fn contradict_attributes() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -578,25 +536,16 @@ async fn contradict_start_time() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -632,7 +581,7 @@ async fn contradict_start_time() { "@id": "chronicle:activity:testactivity", "@type": "prov:Activity", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -646,7 +595,7 @@ async fn contradict_start_time() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -703,25 +652,16 @@ async fn contradict_end_time() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -758,7 +698,7 @@ async fn contradict_end_time() { "@type": "prov:Activity", "endTime": "2018-07-08T09:10:11+00:00", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -771,7 +711,7 @@ async fn contradict_end_time() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -828,25 +768,16 @@ async fn end_activity() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -882,7 +813,7 @@ async fn end_activity() { "@id": "chronicle:activity:testactivity", "@type": "prov:Activity", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -896,7 +827,7 @@ async fn end_activity() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -929,7 +860,7 @@ async fn end_activity() { "@type": "prov:Activity", "endTime": "2014-07-08T09:10:11+00:00", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -943,7 +874,7 @@ async fn end_activity() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -985,25 +916,16 @@ async fn activity_use() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:test" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:test" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -1049,7 +971,7 @@ async fn activity_use() { "chronicle:domaintype:test" ], "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": { "test": "test" } @@ -1080,7 +1002,7 @@ async fn activity_use() { "chronicle:domaintype:test" ], "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "used": [ "chronicle:entity:testentity" ], @@ -1092,7 +1014,7 @@ async fn activity_use() { "@id": "chronicle:entity:testentity", "@type": "prov:Entity", "externalId": "testentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} } ] @@ -1125,7 +1047,7 @@ async fn activity_use() { ], "endTime": "2014-07-08T09:10:11+00:00", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -1143,7 +1065,7 @@ async fn activity_use() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -1185,25 +1107,16 @@ async fn activity_generate() { .unwrap(), @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:activity:testactivity", - "@type": [ - "prov:Activity", - "chronicle:domaintype:test" - ], - "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "test": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:activity:testactivity", + "@type": [ + "prov:Activity", + "chronicle:domaintype:test" + ], + "externalId": "testactivity", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "test": "test" + } } "###); @@ -1226,7 +1139,7 @@ async fn activity_generate() { "@id": "chronicle:entity:testentity", "@type": "prov:Entity", "externalId": "testentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasGeneratedBy": [ "chronicle:activity:testactivity" @@ -1264,7 +1177,7 @@ async fn derive_entity_abstract() { "@id": "chronicle:entity:testgeneratedentity", "@type": "prov:Entity", "externalId": "testgeneratedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasDerivedFrom": [ "chronicle:entity:testusedentity" @@ -1274,13 +1187,8 @@ async fn derive_entity_abstract() { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -1319,20 +1227,15 @@ async fn derive_entity_primary_source() { "hadPrimarySource": [ "chronicle:entity:testusedentity" ], - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} }, { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -1368,7 +1271,7 @@ async fn derive_entity_revision() { "@id": "chronicle:entity:testgeneratedentity", "@type": "prov:Entity", "externalId": "testgeneratedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasRevisionOf": [ "chronicle:entity:testusedentity" @@ -1378,13 +1281,8 @@ async fn derive_entity_revision() { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -1420,7 +1318,7 @@ async fn derive_entity_quotation() { "@id": "chronicle:entity:testgeneratedentity", "@type": "prov:Entity", "externalId": "testgeneratedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasQuotedFrom": [ "chronicle:entity:testusedentity" @@ -1430,13 +1328,8 @@ async fn derive_entity_quotation() { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } diff --git a/crates/chronicle-test-infrastructure/src/cli_test.rs b/crates/chronicle-test-infrastructure/src/cli_test.rs index 984418f0..c882cad3 100644 --- a/crates/chronicle-test-infrastructure/src/cli_test.rs +++ b/crates/chronicle-test-infrastructure/src/cli_test.rs @@ -79,27 +79,18 @@ async fn agent_define() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:test_agent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:testAgent" - ], - "externalId": "test_agent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": false, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:test_agent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:testAgent" + ], + "externalId": "test_agent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": false, + "TestInt": 23, + "TestString": "test" + } } "###); } @@ -117,27 +108,18 @@ async fn agent_define_id() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:test_agent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:testAgent" - ], - "externalId": "test_agent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": false, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:test_agent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:testAgent" + ], + "externalId": "test_agent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": false, + "TestInt": 23, + "TestString": "test" + } } "###); } @@ -157,27 +139,18 @@ async fn agent_use() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:agent:testagent", - "@type": [ - "prov:Agent", - "chronicle:domaintype:testAgent" - ], - "externalId": "testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": true, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:agent:testagent", + "@type": [ + "prov:Agent", + "chronicle:domaintype:testAgent" + ], + "externalId": "testagent", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": true, + "TestInt": 23, + "TestString": "test" + } } "###); @@ -205,7 +178,7 @@ async fn agent_use() { "@id": "chronicle:activity:testactivity", "@type": "prov:Activity", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -219,7 +192,7 @@ async fn agent_use() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -240,27 +213,18 @@ async fn entity_define() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:entity:test_entity", - "@type": [ - "prov:Entity", - "chronicle:domaintype:testEntity" - ], - "externalId": "test_entity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": false, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:entity:test_entity", + "@type": [ + "prov:Entity", + "chronicle:domaintype:testEntity" + ], + "externalId": "test_entity", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": false, + "TestInt": 23, + "TestString": "test" + } } "###); } @@ -278,27 +242,18 @@ async fn entity_define_id() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:entity:test_entity", - "@type": [ - "prov:Entity", - "chronicle:domaintype:testEntity" - ], - "externalId": "test_entity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": false, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:entity:test_entity", + "@type": [ + "prov:Entity", + "chronicle:domaintype:testEntity" + ], + "externalId": "test_entity", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": false, + "TestInt": 23, + "TestString": "test" + } } "###); } @@ -326,7 +281,7 @@ async fn entity_derive_abstract() { "@id": "chronicle:entity:testgeneratedentity", "@type": "prov:Entity", "externalId": "testgeneratedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasDerivedFrom": [ "chronicle:entity:testusedentity" @@ -336,13 +291,8 @@ async fn entity_derive_abstract() { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -375,20 +325,15 @@ async fn entity_derive_primary_source() { "hadPrimarySource": [ "chronicle:entity:testusedentity" ], - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} }, { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -418,7 +363,7 @@ async fn entity_derive_revision() { "@id": "chronicle:entity:testgeneratedentity", "@type": "prov:Entity", "externalId": "testgeneratedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasRevisionOf": [ "chronicle:entity:testusedentity" @@ -428,13 +373,8 @@ async fn entity_derive_revision() { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -464,7 +404,7 @@ async fn entity_derive_quotation() { "@id": "chronicle:entity:testgeneratedentity", "@type": "prov:Entity", "externalId": "testgeneratedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasQuotedFrom": [ "chronicle:entity:testusedentity" @@ -474,13 +414,8 @@ async fn entity_derive_quotation() { "@id": "chronicle:entity:testusedentity", "@type": "prov:Entity", "externalId": "testusedentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" } ] } @@ -497,27 +432,18 @@ async fn activity_define() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:activity:test_activity", - "@type": [ - "prov:Activity", - "chronicle:domaintype:testActivity" - ], - "externalId": "test_activity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": false, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:activity:test_activity", + "@type": [ + "prov:Activity", + "chronicle:domaintype:testActivity" + ], + "externalId": "test_activity", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": false, + "TestInt": 23, + "TestString": "test" + } } "###); } @@ -535,27 +461,18 @@ async fn activity_define_id() { ).unwrap() , @r###" { "@context": "http://chronicle.works/chr/1.0/c.jsonld", - "@graph": [ - { - "@id": "chronicle:activity:test_activity", - "@type": [ - "prov:Activity", - "chronicle:domaintype:testActivity" - ], - "externalId": "test_activity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "value": { - "TestBool": false, - "TestInt": 23, - "TestString": "test" - } - }, - { - "@id": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", - "@type": "chronicle:Namespace", - "externalId": "testns" - } - ] + "@id": "chronicle:activity:test_activity", + "@type": [ + "prov:Activity", + "chronicle:domaintype:testActivity" + ], + "externalId": "test_activity", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", + "value": { + "TestBool": false, + "TestInt": 23, + "TestString": "test" + } } "###); } @@ -591,7 +508,7 @@ async fn activity_start() { "@id": "chronicle:activity:testactivity", "@type": "prov:Activity", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -605,7 +522,7 @@ async fn activity_start() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -655,7 +572,7 @@ async fn activity_end() { "@type": "prov:Activity", "endTime": "2014-08-09T09:10:12+00:00", "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:qualifiedAssociation": { "@id": "chronicle:association:testagent:testactivity:role=" }, @@ -669,7 +586,7 @@ async fn activity_end() { "@id": "chronicle:association:testagent:testactivity:role=", "@type": "prov:Association", "agent": "chronicle:agent:testagent", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "prov:hadActivity": { "@id": "chronicle:activity:testactivity" } @@ -704,7 +621,7 @@ async fn activity_generate() { "@id": "chronicle:entity:testentity", "@type": "prov:Entity", "externalId": "testentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {}, "wasGeneratedBy": [ "chronicle:activity:testactivity" @@ -753,7 +670,7 @@ async fn activity_use() { "chronicle:domaintype:testActivity" ], "externalId": "testactivity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "used": [ "chronicle:entity:testentity" ], @@ -767,7 +684,7 @@ async fn activity_use() { "@id": "chronicle:entity:testentity", "@type": "prov:Entity", "externalId": "testentity", - "namespace": "chronicle:ns:testns:5a0ab5b8-eeb7-4812-9fe3-6dd69bd20cea", + "namespace": "chronicle:ns:testns:11111111-1111-1111-1111-111111111111", "value": {} } ] diff --git a/crates/chronicle-test-infrastructure/src/substitutes/mod.rs b/crates/chronicle-test-infrastructure/src/substitutes/mod.rs index 9e24708d..b002e0c1 100644 --- a/crates/chronicle-test-infrastructure/src/substitutes/mod.rs +++ b/crates/chronicle-test-infrastructure/src/substitutes/mod.rs @@ -10,6 +10,7 @@ use common::{ prov::{ChronicleTransactionId, ProvModel}, }; +use pallet_chronicle::NamespaceId; use uuid::Uuid; use chronicle_signing::{ @@ -152,7 +153,10 @@ pub async fn test_api<'a>() -> TestDispatch<'a> { embed_substrate.clone(), SameUuid, secrets, - vec![], + vec![NamespaceId::from_external_id( + "testns", + Uuid::parse_str("11111111-1111-1111-1111-111111111111").unwrap(), + )], None, liveness_check_interval, ) diff --git a/crates/chronicle-test-infrastructure/src/substitutes/stubstrate.rs b/crates/chronicle-test-infrastructure/src/substitutes/stubstrate.rs index 064f6aa1..ceb69f23 100644 --- a/crates/chronicle-test-infrastructure/src/substitutes/stubstrate.rs +++ b/crates/chronicle-test-infrastructure/src/substitutes/stubstrate.rs @@ -62,7 +62,7 @@ impl LedgerReader for Stubstrate { // The block to start from from_block: FromBlock, // The number of blocks to process before ending the stream - number_of_blocks: Option, + _number_of_blocks: Option, ) -> Result>, Self::Error> { tracing::debug!("Starting state updates stream from block {:?}", from_block); let rx = self.tx.subscribe(); @@ -101,7 +101,7 @@ impl LedgerWriter for Stubstrate { // Submit is used to submit a transaction to the ledger async fn do_submit( &self, - consistency: WriteConsistency, + _consistency: WriteConsistency, submittable: Self::Submittable, ) -> Result { let correlation_id = submittable.correlation_id; @@ -144,9 +144,9 @@ impl SubstrateStateReader for Stubstrate { async fn get_state_entry( &self, - pallet_name: &str, - entry_name: &str, - address: K, + _pallet_name: &str, + _entry_name: &str, + _address: K, ) -> Result, Self::Error> { unimplemented!() } diff --git a/crates/chronicle/src/bootstrap/mod.rs b/crates/chronicle/src/bootstrap/mod.rs index 1316c814..d30858bb 100644 --- a/crates/chronicle/src/bootstrap/mod.rs +++ b/crates/chronicle/src/bootstrap/mod.rs @@ -1,7 +1,10 @@ mod cli; pub mod opa; use api::{ - chronicle_graphql::{ChronicleApiServer, ChronicleGraphQl, JwksUri, SecurityConf, UserInfoUri}, + chronicle_graphql::{ + ChronicleApiServer, ChronicleGraphQl, EndpointSecurityConfiguration, JwksUri, SecurityConf, + UserInfoUri, + }, commands::ApiResponse, Api, ApiDispatch, ApiError, StoreError, UuidGen, }; @@ -137,24 +140,31 @@ pub async fn arrow_api_server( api: &ApiDispatch, pool: &ConnectionPool, addresses: Option>, - _security_conf: &SecurityConf, + security_conf: EndpointSecurityConfiguration, record_batch_size: usize, operation_batch_size: usize, ) -> Result> + Send>, ApiError> { tracing::info!( addresses = ?addresses, - security_conf = ?_security_conf, + allow_anonymous = ?security_conf.allow_anonymous, + jwt_must_claim = ?security_conf.must_claim, record_batch_size, operation_batch_size, "Starting arrow flight with the provided configuration" ); match addresses { - Some(addresses) => - chronicle_arrow::run_flight_service(domain, pool, api, &addresses, record_batch_size) - .await - .map_err(|e| ApiError::ArrowService(e.into())) - .map(|_| Some(futures::future::ready(Ok(())))), + Some(addresses) => chronicle_arrow::run_flight_service( + domain, + pool, + api, + security_conf, + &addresses, + record_batch_size, + ) + .await + .map_err(|e| ApiError::ArrowService(e.into())) + .map(|_| Some(futures::future::ready(Ok(())))), None => Ok(None), } } @@ -553,13 +563,20 @@ where jwks_uri, userinfo_uri, id_claims, - jwt_must_claim, + jwt_must_claim.clone(), allow_anonymous, opa.context().clone(), ); - let arrow = - arrow_api_server(domain, &api, &pool, arrow_interface, &security_conf, 1000, 100); + let arrow = arrow_api_server( + domain, + &api, + &pool, + arrow_interface, + security_conf.as_endpoint_conf(30), + 1000, + 100, + ); let serve_graphql = endpoints.contains(&"graphql".to_string()); let serve_data = endpoints.contains(&"data".to_string()); diff --git a/crates/common/src/attributes.rs b/crates/common/src/attributes.rs index 796c62b9..2b8c8886 100644 --- a/crates/common/src/attributes.rs +++ b/crates/common/src/attributes.rs @@ -1,11 +1,14 @@ #[cfg(feature = "parity-encoding")] use parity_scale_codec::Encode; #[cfg(not(feature = "std"))] -use parity_scale_codec::{alloc::collections::BTreeMap, alloc::string::String, alloc::vec::Vec}; +use parity_scale_codec::{alloc::collections::BTreeMap,alloc::collections::BTreeSet, alloc::string::String, alloc::vec::Vec}; #[cfg(feature = "parity-encoding")] use scale_encode::error::Kind; #[cfg(not(feature = "std"))] use scale_info::{prelude::borrow::ToOwned, prelude::string::ToString, prelude::*}; +#[cfg(feature = "std")] +use std::collections::BTreeSet; + use serde_json::Value; @@ -150,7 +153,10 @@ pub struct Attributes { } impl Attributes { - pub fn new(typ: Option, items: Vec) -> Self { + pub fn new(typ: Option, mut items: Vec) -> Self { + let mut seen_types = BTreeSet::new(); + items.retain(|attr| seen_types.insert(attr.typ.clone())); + items.sort_by(|a, b| a.typ.cmp(&b.typ)); Self { typ, items } } @@ -180,6 +186,12 @@ impl Attributes { } pub fn add_item(&mut self, value: Attribute) { - self.items.push(value); + if !self.items.iter().any(|item| item.typ == value.typ) { + if let Some(pos) = self.items.iter().position(|item| item.typ > value.typ) { + self.items.insert(pos, value); + } else { + self.items.push(value); + } + } } } diff --git a/crates/common/src/opa/core.rs b/crates/common/src/opa/core.rs index 3acd4849..42e5d5f3 100644 --- a/crates/common/src/opa/core.rs +++ b/crates/common/src/opa/core.rs @@ -320,7 +320,7 @@ impl MaxEncodedLen for OpaSettings { #[cfg(feature = "parity-encoding")] pub mod codec { use super::*; - use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; + use parity_scale_codec::{Decode, Encode}; use scale_decode::DecodeAsType; use scale_encode::EncodeAsType; diff --git a/crates/common/src/prov/model/json_ld/from_json_ld.rs b/crates/common/src/prov/model/json_ld/from_json_ld.rs index e0182066..ae57834c 100644 --- a/crates/common/src/prov/model/json_ld/from_json_ld.rs +++ b/crates/common/src/prov/model/json_ld/from_json_ld.rs @@ -482,107 +482,93 @@ impl ProvModel { Ok(()) } } - trait Operation { - fn namespace(&self) -> NamespaceId; - fn agent(&self) -> AgentId; - fn delegate(&self) -> AgentId; - fn responsible(&self) -> AgentId; - fn optional_activity(&self) -> Option; - fn activity(&self) -> ActivityId; + fn namespace(&self) -> Option; + fn agent(&self) -> Option; + fn delegate(&self) -> Option; + fn responsible(&self) -> Option; + + fn activity(&self) -> Option; fn optional_role(&self) -> Option; - fn start_time(&self) -> String; + fn start_time(&self) -> Option; fn locator(&self) -> Option; - fn end_time(&self) -> String; - fn entity(&self) -> EntityId; - fn used_entity(&self) -> EntityId; + fn end_time(&self) -> Option; + fn entity(&self) -> Option; + fn used_entity(&self) -> Option; fn derivation(&self) -> DerivationType; fn domain(&self) -> Option; fn attributes(&self) -> Vec; - fn informing_activity(&self) -> ActivityId; + fn informing_activity(&self) -> Option; } impl Operation for Node { - fn namespace(&self) -> NamespaceId { + fn namespace(&self) -> Option { let mut uuid_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::NamespaceUuid)); - let uuid = uuid_objects.next().unwrap().as_str().unwrap(); + let uuid = uuid_objects.next()?.as_str()?; let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::NamespaceName)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - let uuid = uuid::Uuid::parse_str(uuid).unwrap(); - NamespaceId::from_external_id(external_id, uuid) + let external_id = name_objects.next()?.as_str()?; + let uuid = uuid::Uuid::parse_str(uuid).ok()?; + Some(NamespaceId::from_external_id(external_id, uuid)) } - fn agent(&self) -> AgentId { + fn agent(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::AgentName)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - AgentId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(AgentId::from_external_id(external_id)) } - fn delegate(&self) -> AgentId { + fn delegate(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::DelegateId)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - AgentId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(AgentId::from_external_id(external_id)) } - fn optional_activity(&self) -> Option { - let mut name_objects = - self.get(&id_from_iri_string(vocab::ChronicleOperation::ActivityName)); - let object = match name_objects.next() { - Some(object) => object, - None => return None, - }; - Some(ActivityId::from_external_id(object.as_str().unwrap())) - } - - fn start_time(&self) -> String { + fn start_time(&self) -> Option { let mut objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::StartActivityTime)); - let time = objects.next().unwrap().as_str().unwrap(); - time.to_owned() + let time = objects.next()?.as_str()?; + Some(time.to_owned()) } - fn end_time(&self) -> String { + fn end_time(&self) -> Option { let mut objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::EndActivityTime)); - let time = objects.next().unwrap().as_str().unwrap(); - time.to_owned() + let time = objects.next()?.as_str()?; + Some(time.to_owned()) } - fn entity(&self) -> EntityId { + fn entity(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::EntityName)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - EntityId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(EntityId::from_external_id(external_id)) } - fn used_entity(&self) -> EntityId { + fn used_entity(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::UsedEntityName)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - EntityId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(EntityId::from_external_id(external_id)) } fn derivation(&self) -> DerivationType { let mut objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::DerivationType)); - let derivation = match objects.next() { - Some(object) => object.as_str().unwrap(), - None => return DerivationType::None, - }; - - match derivation { - "Revision" => DerivationType::Revision, - "Quotation" => DerivationType::Quotation, - "PrimarySource" => DerivationType::PrimarySource, - _ => unreachable!(), + if let Some(object) = objects.next() { + if let Some(derivation) = object.as_str() { + return match derivation { + "Revision" => DerivationType::Revision, + "Quotation" => DerivationType::Quotation, + "PrimarySource" => DerivationType::PrimarySource, + _ => DerivationType::None, + }; + } } + DerivationType::None } fn domain(&self) -> Option { let mut objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::DomaintypeId)); - let d = match objects.next() { - Some(object) => object.as_str().unwrap(), - None => return None, - }; + let d = objects.next()?.as_str()?; Some(DomaintypeId::from_external_id(d)) } @@ -613,45 +599,37 @@ impl Operation for Node { .collect() } - fn responsible(&self) -> AgentId { + fn responsible(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::ResponsibleId)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - AgentId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(AgentId::from_external_id(external_id)) } fn optional_role(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::Role)); - let object = match name_objects.next() { - Some(object) => object, - None => return None, - }; - Some(Role::from(object.as_str().unwrap())) + let object = name_objects.next()?; + Some(Role::from(object.as_str()?)) } - fn activity(&self) -> ActivityId { + fn activity(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::ActivityName)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - ActivityId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(ActivityId::from_external_id(external_id)) } fn locator(&self) -> Option { let mut objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::Locator)); - - let locator = match objects.next() { - Some(object) => object, - None => return None, - }; - - Some(locator.as_str().unwrap().to_owned()) + let locator = objects.next()?; + Some(locator.as_str()?.to_owned()) } - fn informing_activity(&self) -> ActivityId { + fn informing_activity(&self) -> Option { let mut name_objects = self.get(&id_from_iri_string(vocab::ChronicleOperation::InformingActivityName)); - let external_id = name_objects.next().unwrap().as_str().unwrap(); - ActivityId::from_external_id(external_id) + let external_id = name_objects.next()?.as_str()?; + Some(ActivityId::from_external_id(external_id)) } } @@ -669,19 +647,19 @@ impl ChronicleOperation { let o = object.value().inner().as_node().ok_or(ProcessorError::NotANode(json.clone()))?; if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::CreateNamespace)) { - let namespace = o.namespace(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; Ok(ChronicleOperation::CreateNamespace(CreateNamespace { id: namespace })) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::AgentExists)) { - let namespace = o.namespace(); - let agent_id = o.agent(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let agent_id = o.agent().ok_or(ProcessorError::MissingAgent)?; Ok(ChronicleOperation::AgentExists(AgentExists { namespace, id: agent_id })) } else if o .has_type(&id_from_iri_string(vocab::ChronicleOperation::AgentActsOnBehalfOf)) { - let namespace = o.namespace(); - let delegate_id = o.delegate(); - let responsible_id = o.responsible(); - let activity_id = o.optional_activity(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let delegate_id = o.delegate().ok_or(ProcessorError::MissingAgent)?; + let responsible_id = o.responsible().ok_or(ProcessorError::MissingAgent)?; + let activity_id = o.activity(); Ok(ChronicleOperation::AgentActsOnBehalfOf(ActsOnBehalfOf::new( namespace, @@ -691,64 +669,47 @@ impl ChronicleOperation { o.optional_role(), ))) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::ActivityExists)) { - let namespace = o.namespace(); - if let Some(activity_id) = o.optional_activity() { - Ok(ChronicleOperation::ActivityExists(ActivityExists { - namespace, - id: activity_id, - })) - } else { - Err(ProcessorError::MissingActivity) - } + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let activity_id = o.activity().ok_or(ProcessorError::MissingActivity)?; + Ok(ChronicleOperation::ActivityExists(ActivityExists { + namespace, + id: activity_id, + })) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::StartActivity)) { - let namespace = o.namespace(); - if let Some(id) = o.optional_activity() { - match o.start_time().parse::>() { - Ok(time) => Ok(ChronicleOperation::start_activity(namespace, id, time)), - Err(e) => Err(ProcessorError::Time(e)), - } - } else { - Err(ProcessorError::MissingActivity) + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let id = o.activity().ok_or(ProcessorError::MissingActivity)?; + let time_str = o.start_time().ok_or(ProcessorError::MissingTime)?; + match time_str.parse::>() { + Ok(time) => Ok(ChronicleOperation::start_activity(namespace, id, time)), + Err(e) => Err(ProcessorError::Time(e)), } } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::EndActivity)) { - let namespace = o.namespace(); - if let Some(id) = o.optional_activity() { - match o.start_time().parse::>() { - Ok(time) => Ok(ChronicleOperation::end_activity(namespace, id, time)), - Err(e) => Err(ProcessorError::Time(e)), - } - } else { - Err(ProcessorError::MissingActivity) + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let id = o.activity().ok_or(ProcessorError::MissingActivity)?; + let time_str = o.end_time().ok_or(ProcessorError::MissingTime)?; + match time_str.parse::>() { + Ok(time) => Ok(ChronicleOperation::end_activity(namespace, id, time)), + Err(e) => Err(ProcessorError::Time(e)), } } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::ActivityUses)) { - let namespace = o.namespace(); - let id = o.entity(); - if let Some(activity) = o.optional_activity() { - Ok(ChronicleOperation::ActivityUses(ActivityUses { namespace, id, activity })) - } else { - Err(ProcessorError::MissingActivity) - } + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let id = o.entity().ok_or(ProcessorError::MissingEntity)?; + let activity = o.activity().ok_or(ProcessorError::MissingActivity)?; + Ok(ChronicleOperation::ActivityUses(ActivityUses { namespace, id, activity })) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::EntityExists)) { - let namespace = o.namespace(); - let entity_id = o.entity(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let entity_id = o.entity().ok_or(ProcessorError::MissingEntity)?; Ok(ChronicleOperation::EntityExists(EntityExists { namespace, id: entity_id })) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::WasGeneratedBy)) { - let namespace = o.namespace(); - let id = o.entity(); - if let Some(activity) = o.optional_activity() { - Ok(ChronicleOperation::WasGeneratedBy(WasGeneratedBy { - namespace, - id, - activity, - })) - } else { - Err(ProcessorError::MissingActivity) - } + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let id = o.entity().ok_or(ProcessorError::MissingEntity)?; + let activity = o.activity().ok_or(ProcessorError::MissingActivity)?; + Ok(ChronicleOperation::WasGeneratedBy(WasGeneratedBy { namespace, id, activity })) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::EntityDerive)) { - let namespace = o.namespace(); - let id = o.entity(); - let used_id = o.used_entity(); - let activity_id = o.optional_activity(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let id = o.entity().ok_or(ProcessorError::MissingEntity)?; + let used_id = o.used_entity().ok_or(ProcessorError::MissingEntity)?; + let activity_id = o.activity(); let typ = o.derivation(); Ok(ChronicleOperation::EntityDerive(EntityDerive { namespace, @@ -758,9 +719,8 @@ impl ChronicleOperation { typ, })) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::SetAttributes)) { - let namespace = o.namespace(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; let domain = o.domain(); - let attrs = o.attributes(); let attributes = Attributes::new(domain, attrs); @@ -768,15 +728,15 @@ impl ChronicleOperation { if o.has_key(&Term::Id(id_from_iri_string( vocab::ChronicleOperation::EntityName, ))) { - let id = o.entity(); + let id = o.entity().ok_or(ProcessorError::MissingEntity)?; SetAttributes::Entity { namespace, id, attributes } } else if o.has_key(&Term::Id(id_from_iri_string( vocab::ChronicleOperation::AgentName, ))) { - let id = o.agent(); + let id = o.agent().ok_or(ProcessorError::MissingAgent)?; SetAttributes::Agent { namespace, id, attributes } } else { - let id = o.optional_activity().unwrap(); + let id = o.activity().ok_or(ProcessorError::MissingActivity)?; SetAttributes::Activity { namespace, id, attributes } } }; @@ -785,22 +745,23 @@ impl ChronicleOperation { } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::WasAssociatedWith)) { Ok(ChronicleOperation::WasAssociatedWith(WasAssociatedWith::new( - o.namespace(), - o.activity(), - o.agent(), + o.namespace().ok_or(ProcessorError::MissingNamespace)?, + o.activity().ok_or(ProcessorError::MissingActivity)?, + o.agent().ok_or(ProcessorError::MissingAgent)?, o.optional_role(), ))) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::WasAttributedTo)) { Ok(ChronicleOperation::WasAttributedTo(WasAttributedTo::new( - o.namespace(), - o.entity(), - o.agent(), + o.namespace().ok_or(ProcessorError::MissingNamespace)?, + o.entity().ok_or(ProcessorError::MissingEntity)?, + o.agent().ok_or(ProcessorError::MissingAgent)?, o.optional_role(), ))) } else if o.has_type(&id_from_iri_string(vocab::ChronicleOperation::WasInformedBy)) { - let namespace = o.namespace(); - let activity = o.activity(); - let informing_activity = o.informing_activity(); + let namespace = o.namespace().ok_or(ProcessorError::MissingNamespace)?; + let activity = o.activity().ok_or(ProcessorError::MissingActivity)?; + let informing_activity = + o.informing_activity().ok_or(ProcessorError::MissingActivity)?; Ok(ChronicleOperation::WasInformedBy(WasInformedBy { namespace, activity, diff --git a/crates/common/src/prov/model/mod.rs b/crates/common/src/prov/model/mod.rs index 5b4f1896..47615bb7 100644 --- a/crates/common/src/prov/model/mod.rs +++ b/crates/common/src/prov/model/mod.rs @@ -95,6 +95,20 @@ pub enum ProcessorError { #[error("Missing activity")] MissingActivity, + + #[error("Missing namespace")] + MissingNamespace, + #[error("Missing entity")] + MissingEntity, + #[error("Missing agent")] + MissingAgent, + #[error("Missing time")] + MissingTime, + #[error("Missing derivation")] + MissingDerivation, + #[error("Missing domain type")] + MissingDomainType, + #[error("OpaExecutorError: {0}")] OpaExecutor( #[from] diff --git a/crates/common/src/prov/operations.rs b/crates/common/src/prov/operations.rs index edcf3db2..9e282689 100644 --- a/crates/common/src/prov/operations.rs +++ b/crates/common/src/prov/operations.rs @@ -12,6 +12,8 @@ use diesel::{ #[cfg(not(feature = "std"))] use parity_scale_codec::alloc::string::String; +#[cfg(not(feature = "std"))] +use scale_info::prelude::{vec::Vec,vec}; use crate::attributes::Attributes; diff --git a/crates/opactl/src/test/mod.rs b/crates/opactl/src/test/mod.rs index 8e4b129f..e703d3ec 100644 --- a/crates/opactl/src/test/mod.rs +++ b/crates/opactl/src/test/mod.rs @@ -50,7 +50,10 @@ async fn bootstrap_root_state() -> (String, Stubstrate, TempDir) { (root_key, stubstrate, keystore) } + +//TODO: downloads #[tokio::test] +#[ignore] async fn bootstrap_root_and_get_key() { let (_root_key, opa_tp, _keystore) = bootstrap_root_state().await; //Generate a key pem and set env vars @@ -214,39 +217,39 @@ async fn register_and_rotate_key() { ".**.key" => "[pem]", ".**.correlation_id" => "[correlation_id]" } ,@r###" - --- - WaitedAndFound: - KeyUpdate: - id: test - current: - key: "[pem]" - version: 1 - expired: - key: "[pem]" - version: 0 - "###); + --- + WaitedAndFound: + KeyUpdate: + keys: + id: test + current: + key: "[pem]" + version: 1 + expired: + key: "[pem]" + version: 0 + correlation_id: "[correlation_id]" + "###); insta::assert_yaml_snapshot!(opa_tp.stored_keys(), { ".**.date" => "[date]", ".**.key" => "[pem]", ".**.correlation_id" => "[correlation_id]" } ,@r###" - --- - - - 7ed19313e8ece6c4f5551b9bd1090797ad25c6d85f7b523b2214d4fe448372279aa95c - - current: - key: "[pem]" - version: 0 - expired: ~ - id: root - - - 7ed19336d8b5677c39a7b872910f948944dd84ba014846c81fcd53fe1fd5289b9dfd1c - - current: - key: "[pem]" - version: 1 - expired: - key: "[pem]" - version: 0 - id: test - "###); + --- + - id: test + current: + key: "[pem]" + version: 1 + expired: + key: "[pem]" + version: 0 + - id: root + current: + key: "[pem]" + version: 0 + expired: ~ + "###); } #[tokio::test] @@ -324,20 +327,43 @@ async fn set_and_update_policy() { ".**.key" => "[pem]", ".**.correlation_id" => "[correlation_id]", } ,@r###" - --- - - - 7ed19313e8ece6c4f5551b9bd1090797ad25c6d85f7b523b2214d4fe448372279aa95c - - current: - key: "[pem]" - version: 0 - expired: ~ - id: root - - - 7ed1931c262a4be700b69974438a35ae56a07ce96778b276c8a061dc254d9862c7ecff - - - 0 - - - 7ed1932b35db049f40833c5c2eaa47e070ce2648c478469a4cdf44ff7a37dd5468208e - - hash: 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d - id: test - policy_address: 7ed1931c262a4be700b69974438a35ae56a07ce96778b276c8a061dc254d9862c7ecff - "###); + --- + - id: test + hash: + - 112 + - 37 + - 224 + - 117 + - 213 + - 226 + - 246 + - 205 + - 227 + - 204 + - 5 + - 26 + - 49 + - 240 + - 118 + - 96 + policy_address: + - 57 + - 55 + - 86 + - 28 + - 76 + - 12 + - 167 + - 194 + - 100 + - 141 + - 152 + - 29 + - 77 + - 122 + - 58 + - 230 + "###); policy.write_all(&[1]).unwrap(); @@ -356,32 +382,87 @@ async fn set_and_update_policy() { ".**.date" => "[date]", ".**.correlation_id" => "[correlation_id]", }, @r###" - --- - WaitedAndFound: - PolicyUpdate: - id: test - hash: b413f47d13ee2fe6c845b2ee141af81de858df4ec549a58b7970bb96645bc8d2 - policy_address: 7ed1931c262a4be700b69974438a35ae56a07ce96778b276c8a061dc254d9862c7ecff - "### ); + --- + WaitedAndFound: + PolicyUpdate: + policy: + id: test + hash: + - 15 + - 22 + - 254 + - 183 + - 126 + - 60 + - 18 + - 155 + - 216 + - 189 + - 76 + - 67 + - 159 + - 18 + - 235 + - 209 + policy_address: + - 57 + - 55 + - 86 + - 28 + - 76 + - 12 + - 167 + - 194 + - 100 + - 141 + - 152 + - 29 + - 77 + - 122 + - 58 + - 230 + correlation_id: "[correlation_id]" + "### ); insta::assert_yaml_snapshot!(opa_tp.stored_policy(), { ".**.date" => "[date]", ".**.key" => "[pem]", } ,@r###" - --- - - - 7ed19313e8ece6c4f5551b9bd1090797ad25c6d85f7b523b2214d4fe448372279aa95c - - current: - key: "[pem]" - version: 0 - expired: ~ - id: root - - - 7ed1931c262a4be700b69974438a35ae56a07ce96778b276c8a061dc254d9862c7ecff - - - 0 - - 1 - - - 7ed1932b35db049f40833c5c2eaa47e070ce2648c478469a4cdf44ff7a37dd5468208e - - hash: b413f47d13ee2fe6c845b2ee141af81de858df4ec549a58b7970bb96645bc8d2 - id: test - policy_address: 7ed1931c262a4be700b69974438a35ae56a07ce96778b276c8a061dc254d9862c7ecff + --- + - id: test + hash: + - 15 + - 22 + - 254 + - 183 + - 126 + - 60 + - 18 + - 155 + - 216 + - 189 + - 76 + - 67 + - 159 + - 18 + - 235 + - 209 + policy_address: + - 57 + - 55 + - 86 + - 28 + - 76 + - 12 + - 167 + - 194 + - 100 + - 141 + - 152 + - 29 + - 77 + - 122 + - 58 - 230 "###); }