From 038218e0d01f809b7f52762990d8dc1e60cdfe4e Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 14:06:19 +0100 Subject: [PATCH 1/8] chore: upgrade ucantone validator --- capabilities/access/claim.go | 13 ------ capabilities/assert/location.go | 11 ----- capabilities/bind.go | 20 --------- capabilities/blob/accept.go | 9 ---- capabilities/blob/add.go | 19 --------- capabilities/blob/allocate.go | 21 ---------- capabilities/blob/list.go | 9 ---- capabilities/blob/remove.go | 11 ----- capabilities/blob/replica/allocate.go | 20 --------- capabilities/blob/replica/transfer.go | 20 --------- capabilities/claim/cache.go | 11 ----- capabilities/content/retrieve.go | 11 ----- capabilities/debug/echo.go | 18 -------- capabilities/gen/main.go | 41 ------------------- capabilities/http/put.go | 11 ----- capabilities/space/info.go | 13 ------ capabilities/upload/add.go | 11 ----- capabilities/upload/list.go | 9 ---- capabilities/upload/remove.go | 11 ----- capabilities/upload/shard/list.go | 9 ---- {capabilities => commands}/access/cbor_gen.go | 0 commands/access/claim.go | 11 +++++ {capabilities => commands}/access/confirm.go | 6 +-- {capabilities => commands}/access/delegate.go | 8 ++-- {capabilities => commands}/access/gen/main.go | 2 +- {capabilities => commands}/access/json_gen.go | 0 {capabilities => commands}/access/request.go | 4 +- {capabilities => commands}/access/types.go | 0 {capabilities => commands}/assert/cbor_gen.go | 8 ++-- {capabilities => commands}/assert/equals.go | 6 +-- {capabilities => commands}/assert/gen/main.go | 2 +- {capabilities => commands}/assert/index.go | 6 +-- {capabilities => commands}/assert/json_gen.go | 8 ++-- commands/assert/location.go | 11 +++++ {capabilities => commands}/assert/types.go | 4 +- commands/bind.go | 16 ++++++++ commands/blob/accept.go | 9 ++++ commands/blob/add.go | 7 ++++ commands/blob/allocate.go | 9 ++++ {capabilities => commands}/blob/cbor_gen.go | 4 +- {capabilities => commands}/blob/gen/main.go | 2 +- {capabilities => commands}/blob/json_gen.go | 4 +- commands/blob/list.go | 9 ++++ commands/blob/remove.go | 11 +++++ commands/blob/replica/allocate.go | 7 ++++ .../blob/replica/cbor_gen.go | 0 .../blob/replica/gen/main.go | 2 +- commands/blob/replica/transfer.go | 7 ++++ .../blob/replica/types.go | 0 {capabilities => commands}/blob/replicate.go | 17 +------- {capabilities => commands}/blob/retrieve.go | 6 +-- {capabilities => commands}/blob/types.go | 4 +- {capabilities => commands}/cbor_gen.go | 2 +- {capabilities => commands}/cbor_url.go | 2 +- commands/claim/cache.go | 11 +++++ {capabilities => commands}/claim/cbor_gen.go | 0 {capabilities => commands}/claim/gen/main.go | 2 +- {capabilities => commands}/claim/json_gen.go | 0 {capabilities => commands}/claim/types.go | 0 .../content/cbor_gen.maps.go | 0 .../content/cbor_gen.tuples.go | 0 .../content/gen/main.go | 2 +- .../content/json_gen.maps.go | 0 .../content/json_gen.tuples.go | 0 commands/content/retrieve.go | 11 +++++ {capabilities => commands}/content/types.go | 0 {capabilities => commands}/debug/cbor_gen.go | 0 commands/debug/echo.go | 9 ++++ {capabilities => commands}/debug/gen/main.go | 2 +- {capabilities => commands}/debug/json_gen.go | 0 {capabilities => commands}/debug/types.go | 0 commands/gen/main.go | 41 +++++++++++++++++++ {capabilities => commands}/http/cbor_gen.go | 0 {capabilities => commands}/http/gen/main.go | 2 +- {capabilities => commands}/http/json_gen.go | 0 commands/http/put.go | 11 +++++ {capabilities => commands}/http/types.go | 2 +- {capabilities => commands}/index/add.go | 6 +-- {capabilities => commands}/index/cbor_gen.go | 0 {capabilities => commands}/index/gen/main.go | 2 +- {capabilities => commands}/index/json_gen.go | 0 {capabilities => commands}/index/types.go | 0 {capabilities => commands}/json_gen.go | 2 +- {capabilities => commands}/provider/add.go | 4 +- .../provider/cbor_gen.go | 0 .../provider/gen/main.go | 2 +- .../provider/json_gen.go | 0 {capabilities => commands}/provider/types.go | 0 {capabilities => commands}/space/cbor_gen.go | 0 .../space/egress/cbor_gen.go | 4 +- .../space/egress/gen/main.go | 2 +- .../space/egress/json_gen.go | 4 +- .../space/egress/track.go | 4 +- .../space/egress/types.go | 4 +- {capabilities => commands}/space/gen/main.go | 2 +- commands/space/info.go | 13 ++++++ {capabilities => commands}/space/json_gen.go | 0 {capabilities => commands}/space/types.go | 0 {capabilities => commands}/types.go | 4 +- .../ucan/attest/cbor_gen.go | 0 .../ucan/attest/gen/main.go | 2 +- .../ucan/attest/json_gen.go | 0 .../ucan/attest/proof.go | 6 +-- .../ucan/attest/types.go | 0 {capabilities => commands}/ucan/cbor_gen.go | 0 {capabilities => commands}/ucan/conclude.go | 6 +-- {capabilities => commands}/ucan/gen/main.go | 2 +- {capabilities => commands}/ucan/json_gen.go | 0 {capabilities => commands}/ucan/types.go | 0 commands/upload/add.go | 11 +++++ {capabilities => commands}/upload/cbor_gen.go | 0 {capabilities => commands}/upload/gen/main.go | 2 +- {capabilities => commands}/upload/json_gen.go | 0 commands/upload/list.go | 9 ++++ commands/upload/remove.go | 11 +++++ .../upload/shard/cbor_gen.go | 0 .../upload/shard/gen/main.go | 2 +- .../upload/shard/json_gen.go | 0 commands/upload/shard/list.go | 9 ++++ .../upload/shard/types.go | 0 {capabilities => commands}/upload/types.go | 0 go.mod | 4 +- go.sum | 8 +++- ucan/attestations.go | 2 +- ucan/attestations_test.go | 2 +- ucan/proof_store_test.go | 2 +- ucan/retrieval/client_test.go | 10 ++--- ucan/retrieval/server_test.go | 9 ++-- 128 files changed, 330 insertions(+), 405 deletions(-) delete mode 100644 capabilities/access/claim.go delete mode 100644 capabilities/assert/location.go delete mode 100644 capabilities/bind.go delete mode 100644 capabilities/blob/accept.go delete mode 100644 capabilities/blob/add.go delete mode 100644 capabilities/blob/allocate.go delete mode 100644 capabilities/blob/list.go delete mode 100644 capabilities/blob/remove.go delete mode 100644 capabilities/blob/replica/allocate.go delete mode 100644 capabilities/blob/replica/transfer.go delete mode 100644 capabilities/claim/cache.go delete mode 100644 capabilities/content/retrieve.go delete mode 100644 capabilities/debug/echo.go delete mode 100644 capabilities/gen/main.go delete mode 100644 capabilities/http/put.go delete mode 100644 capabilities/space/info.go delete mode 100644 capabilities/upload/add.go delete mode 100644 capabilities/upload/list.go delete mode 100644 capabilities/upload/remove.go delete mode 100644 capabilities/upload/shard/list.go rename {capabilities => commands}/access/cbor_gen.go (100%) create mode 100644 commands/access/claim.go rename {capabilities => commands}/access/confirm.go (86%) rename {capabilities => commands}/access/delegate.go (58%) rename {capabilities => commands}/access/gen/main.go (94%) rename {capabilities => commands}/access/json_gen.go (100%) rename {capabilities => commands}/access/request.go (81%) rename {capabilities => commands}/access/types.go (100%) rename {capabilities => commands}/assert/cbor_gen.go (98%) rename {capabilities => commands}/assert/equals.go (50%) rename {capabilities => commands}/assert/gen/main.go (94%) rename {capabilities => commands}/assert/index.go (56%) rename {capabilities => commands}/assert/json_gen.go (99%) create mode 100644 commands/assert/location.go rename {capabilities => commands}/assert/types.go (89%) create mode 100644 commands/bind.go create mode 100644 commands/blob/accept.go create mode 100644 commands/blob/add.go create mode 100644 commands/blob/allocate.go rename {capabilities => commands}/blob/cbor_gen.go (99%) rename {capabilities => commands}/blob/gen/main.go (95%) rename {capabilities => commands}/blob/json_gen.go (99%) create mode 100644 commands/blob/list.go create mode 100644 commands/blob/remove.go create mode 100644 commands/blob/replica/allocate.go rename {capabilities => commands}/blob/replica/cbor_gen.go (100%) rename {capabilities => commands}/blob/replica/gen/main.go (91%) create mode 100644 commands/blob/replica/transfer.go rename {capabilities => commands}/blob/replica/types.go (100%) rename {capabilities => commands}/blob/replicate.go (64%) rename {capabilities => commands}/blob/retrieve.go (70%) rename {capabilities => commands}/blob/types.go (97%) rename {capabilities => commands}/cbor_gen.go (98%) rename {capabilities => commands}/cbor_url.go (98%) create mode 100644 commands/claim/cache.go rename {capabilities => commands}/claim/cbor_gen.go (100%) rename {capabilities => commands}/claim/gen/main.go (93%) rename {capabilities => commands}/claim/json_gen.go (100%) rename {capabilities => commands}/claim/types.go (100%) rename {capabilities => commands}/content/cbor_gen.maps.go (100%) rename {capabilities => commands}/content/cbor_gen.tuples.go (100%) rename {capabilities => commands}/content/gen/main.go (95%) rename {capabilities => commands}/content/json_gen.maps.go (100%) rename {capabilities => commands}/content/json_gen.tuples.go (100%) create mode 100644 commands/content/retrieve.go rename {capabilities => commands}/content/types.go (100%) rename {capabilities => commands}/debug/cbor_gen.go (100%) create mode 100644 commands/debug/echo.go rename {capabilities => commands}/debug/gen/main.go (93%) rename {capabilities => commands}/debug/json_gen.go (100%) rename {capabilities => commands}/debug/types.go (100%) create mode 100644 commands/gen/main.go rename {capabilities => commands}/http/cbor_gen.go (100%) rename {capabilities => commands}/http/gen/main.go (93%) rename {capabilities => commands}/http/json_gen.go (100%) create mode 100644 commands/http/put.go rename {capabilities => commands}/http/types.go (88%) rename {capabilities => commands}/index/add.go (65%) rename {capabilities => commands}/index/cbor_gen.go (100%) rename {capabilities => commands}/index/gen/main.go (93%) rename {capabilities => commands}/index/json_gen.go (100%) rename {capabilities => commands}/index/types.go (100%) rename {capabilities => commands}/json_gen.go (98%) rename {capabilities => commands}/provider/add.go (77%) rename {capabilities => commands}/provider/cbor_gen.go (100%) rename {capabilities => commands}/provider/gen/main.go (93%) rename {capabilities => commands}/provider/json_gen.go (100%) rename {capabilities => commands}/provider/types.go (100%) rename {capabilities => commands}/space/cbor_gen.go (100%) rename {capabilities => commands}/space/egress/cbor_gen.go (97%) rename {capabilities => commands}/space/egress/gen/main.go (92%) rename {capabilities => commands}/space/egress/json_gen.go (98%) rename {capabilities => commands}/space/egress/track.go (77%) rename {capabilities => commands}/space/egress/types.go (87%) rename {capabilities => commands}/space/gen/main.go (93%) create mode 100644 commands/space/info.go rename {capabilities => commands}/space/json_gen.go (100%) rename {capabilities => commands}/space/types.go (100%) rename {capabilities => commands}/types.go (78%) rename {capabilities => commands}/ucan/attest/cbor_gen.go (100%) rename {capabilities => commands}/ucan/attest/gen/main.go (92%) rename {capabilities => commands}/ucan/attest/json_gen.go (100%) rename {capabilities => commands}/ucan/attest/proof.go (60%) rename {capabilities => commands}/ucan/attest/types.go (100%) rename {capabilities => commands}/ucan/cbor_gen.go (100%) rename {capabilities => commands}/ucan/conclude.go (67%) rename {capabilities => commands}/ucan/gen/main.go (93%) rename {capabilities => commands}/ucan/json_gen.go (100%) rename {capabilities => commands}/ucan/types.go (100%) create mode 100644 commands/upload/add.go rename {capabilities => commands}/upload/cbor_gen.go (100%) rename {capabilities => commands}/upload/gen/main.go (94%) rename {capabilities => commands}/upload/json_gen.go (100%) create mode 100644 commands/upload/list.go create mode 100644 commands/upload/remove.go rename {capabilities => commands}/upload/shard/cbor_gen.go (100%) rename {capabilities => commands}/upload/shard/gen/main.go (92%) rename {capabilities => commands}/upload/shard/json_gen.go (100%) create mode 100644 commands/upload/shard/list.go rename {capabilities => commands}/upload/shard/types.go (100%) rename {capabilities => commands}/upload/types.go (100%) diff --git a/capabilities/access/claim.go b/capabilities/access/claim.go deleted file mode 100644 index d127045..0000000 --- a/capabilities/access/claim.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !codegen - -package access - -import "github.com/fil-forge/libforge/capabilities" - -const ClaimCommand = "/access/claim" - -type ClaimArguments = capabilities.Unit - -// Claim can be invoked by an agent to claim a set of delegations from the -// account. -var Claim = capabilities.MustNew[*ClaimArguments](ClaimCommand) diff --git a/capabilities/assert/location.go b/capabilities/assert/location.go deleted file mode 100644 index ceee71b..0000000 --- a/capabilities/assert/location.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package assert - -import "github.com/fil-forge/libforge/capabilities" - -const LocationCommand = "/assert/location" - -type LocationOK = capabilities.Unit - -var Location = capabilities.MustNew[*LocationArguments](LocationCommand) diff --git a/capabilities/bind.go b/capabilities/bind.go deleted file mode 100644 index b347533..0000000 --- a/capabilities/bind.go +++ /dev/null @@ -1,20 +0,0 @@ -package capabilities - -import ( - "github.com/fil-forge/ucantone/ucan" - "github.com/fil-forge/ucantone/validator/bindcap" - "github.com/fil-forge/ucantone/validator/capability" -) - -// MustNew is like [bindcap.New] but panics if the capability cannot be -// constructed. It exists for package-level capability declarations where the -// command and options are static — any error indicates a programming bug -// (malformed command string, invalid option) and should fail loudly at init -// rather than be silently dropped with `, _`. -func MustNew[A bindcap.Arguments](cmd ucan.Command, opts ...capability.Option) *bindcap.Capability[A] { - c, err := bindcap.New[A](cmd, opts...) - if err != nil { - panic(err) - } - return c -} diff --git a/capabilities/blob/accept.go b/capabilities/blob/accept.go deleted file mode 100644 index c347440..0000000 --- a/capabilities/blob/accept.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !codegen - -package blob - -import "github.com/fil-forge/libforge/capabilities" - -const AcceptCommand = "/blob/accept" - -var Accept = capabilities.MustNew[*AcceptArguments](AcceptCommand) diff --git a/capabilities/blob/add.go b/capabilities/blob/add.go deleted file mode 100644 index 2252abb..0000000 --- a/capabilities/blob/add.go +++ /dev/null @@ -1,19 +0,0 @@ -//go:build !codegen - -package blob - -import ( - "github.com/fil-forge/libforge/capabilities" - "github.com/fil-forge/ucantone/ucan/delegation/policy" - "github.com/fil-forge/ucantone/validator/capability" -) - -const AddCommand = "/blob/add" - -var Add = capabilities.MustNew[*AddArguments]( - AddCommand, - capability.WithPolicyBuilder( - policy.GreaterThan(".blob.size", 0), - policy.LessThanOrEqual(".blob.size", MaxBlobSize), - ), -) diff --git a/capabilities/blob/allocate.go b/capabilities/blob/allocate.go deleted file mode 100644 index 0c36ecc..0000000 --- a/capabilities/blob/allocate.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build !codegen - -package blob - -import ( - "github.com/fil-forge/libforge/capabilities" - "github.com/fil-forge/ucantone/ucan/delegation/policy" - "github.com/fil-forge/ucantone/validator/capability" -) - -const MaxBlobSize = 268_435_456 - -const AllocateCommand = "/blob/allocate" - -var Allocate = capabilities.MustNew[*AllocateArguments]( - AllocateCommand, - capability.WithPolicyBuilder( - policy.GreaterThan(".blob.size", 0), - policy.LessThanOrEqual(".blob.size", MaxBlobSize), - ), -) diff --git a/capabilities/blob/list.go b/capabilities/blob/list.go deleted file mode 100644 index 8a35dd8..0000000 --- a/capabilities/blob/list.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !codegen - -package blob - -import "github.com/fil-forge/libforge/capabilities" - -const ListCommand = "/blob/list" - -var List = capabilities.MustNew[*ListArguments](ListCommand) diff --git a/capabilities/blob/remove.go b/capabilities/blob/remove.go deleted file mode 100644 index 1a84061..0000000 --- a/capabilities/blob/remove.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package blob - -import "github.com/fil-forge/libforge/capabilities" - -const RemoveCommand = "/blob/remove" - -type RemoveOK = capabilities.Unit - -var Remove = capabilities.MustNew[*RemoveArguments](RemoveCommand) diff --git a/capabilities/blob/replica/allocate.go b/capabilities/blob/replica/allocate.go deleted file mode 100644 index 4952578..0000000 --- a/capabilities/blob/replica/allocate.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build !codegen - -package replica - -import ( - "github.com/fil-forge/libforge/capabilities" - "github.com/fil-forge/libforge/capabilities/blob" - "github.com/fil-forge/ucantone/ucan/delegation/policy" - "github.com/fil-forge/ucantone/validator/capability" -) - -const AllocateCommand = "/blob/replica/allocate" - -var Allocate = capabilities.MustNew[*AllocateArguments]( - AllocateCommand, - capability.WithPolicyBuilder( - policy.GreaterThan(".blob.size", 0), - policy.LessThanOrEqual(".blob.size", blob.MaxBlobSize), - ), -) diff --git a/capabilities/blob/replica/transfer.go b/capabilities/blob/replica/transfer.go deleted file mode 100644 index 166494d..0000000 --- a/capabilities/blob/replica/transfer.go +++ /dev/null @@ -1,20 +0,0 @@ -//go:build !codegen - -package replica - -import ( - "github.com/fil-forge/libforge/capabilities" - "github.com/fil-forge/libforge/capabilities/blob" - "github.com/fil-forge/ucantone/ucan/delegation/policy" - "github.com/fil-forge/ucantone/validator/capability" -) - -const TransferCommand = "/blob/replica/transfer" - -var Transfer = capabilities.MustNew[*TransferArguments]( - TransferCommand, - capability.WithPolicyBuilder( - policy.GreaterThan(".blob.size", 0), - policy.LessThanOrEqual(".blob.size", blob.MaxBlobSize), - ), -) diff --git a/capabilities/claim/cache.go b/capabilities/claim/cache.go deleted file mode 100644 index 0dc4f9e..0000000 --- a/capabilities/claim/cache.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package claim - -import "github.com/fil-forge/libforge/capabilities" - -const CacheCommand = "/claim/cache" - -type CacheOK = capabilities.Unit - -var Cache = capabilities.MustNew[*CacheArguments](CacheCommand) diff --git a/capabilities/content/retrieve.go b/capabilities/content/retrieve.go deleted file mode 100644 index a4f5c7e..0000000 --- a/capabilities/content/retrieve.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package content - -import "github.com/fil-forge/libforge/capabilities" - -const RetrieveCommand = "/content/retrieve" - -type RetrieveOK = capabilities.Unit - -var Retrieve = capabilities.MustNew[*RetrieveArguments](RetrieveCommand) diff --git a/capabilities/debug/echo.go b/capabilities/debug/echo.go deleted file mode 100644 index 8e5628c..0000000 --- a/capabilities/debug/echo.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build !codegen - -package debug - -import ( - "github.com/fil-forge/libforge/capabilities" - "github.com/fil-forge/ucantone/ucan/delegation/policy" - "github.com/fil-forge/ucantone/validator/capability" -) - -const EchoCommand = "/debug/echo" - -type EchoOK = EchoArguments - -var Echo = capabilities.MustNew[*EchoArguments]( - EchoCommand, - capability.WithPolicyBuilder(policy.NotEqual(".message", "")), -) diff --git a/capabilities/gen/main.go b/capabilities/gen/main.go deleted file mode 100644 index 7692183..0000000 --- a/capabilities/gen/main.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:generate go run -tags codegen . - -package main - -import ( - "os" - - jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities" - cbg "github.com/whyrusleeping/cbor-gen" -) - -const buildTag = "//go:build !codegen\n\n" - -func tag(path string) { - data, err := os.ReadFile(path) - if err != nil { - panic(err) - } - if err := os.WriteFile(path, append([]byte(buildTag), data...), 0644); err != nil { - panic(err) - } -} - -func main() { - models := []any{ - capabilities.Unit{}, - } - const ( - cborFile = "../cbor_gen.go" - jsonFile = "../json_gen.go" - ) - if err := cbg.WriteMapEncodersToFile(cborFile, "capabilities", models...); err != nil { - panic(err) - } - if err := jsg.WriteMapEncodersToFile(jsonFile, "capabilities", models...); err != nil { - panic(err) - } - tag(cborFile) - tag(jsonFile) -} diff --git a/capabilities/http/put.go b/capabilities/http/put.go deleted file mode 100644 index b29bbd8..0000000 --- a/capabilities/http/put.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package http - -import "github.com/fil-forge/libforge/capabilities" - -const PutCommand = "/http/put" - -type PutOK = capabilities.Unit - -var Put = capabilities.MustNew[*PutArguments](PutCommand) diff --git a/capabilities/space/info.go b/capabilities/space/info.go deleted file mode 100644 index 907e016..0000000 --- a/capabilities/space/info.go +++ /dev/null @@ -1,13 +0,0 @@ -//go:build !codegen - -package space - -import "github.com/fil-forge/libforge/capabilities" - -const InfoCommand = "/space/info" - -type InfoArguments = capabilities.Unit - -var Info = capabilities.MustNew[*InfoArguments](InfoCommand) - -const UnknownSpaceErrorName = "UnknownSpace" diff --git a/capabilities/upload/add.go b/capabilities/upload/add.go deleted file mode 100644 index 7a91813..0000000 --- a/capabilities/upload/add.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package upload - -import "github.com/fil-forge/libforge/capabilities" - -const AddCommand = "/upload/add" - -type AddOK = capabilities.Unit - -var Add = capabilities.MustNew[*AddArguments](AddCommand) diff --git a/capabilities/upload/list.go b/capabilities/upload/list.go deleted file mode 100644 index ef093f9..0000000 --- a/capabilities/upload/list.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !codegen - -package upload - -import "github.com/fil-forge/libforge/capabilities" - -const ListCommand = "/upload/list" - -var List = capabilities.MustNew[*ListArguments](ListCommand) diff --git a/capabilities/upload/remove.go b/capabilities/upload/remove.go deleted file mode 100644 index d56089a..0000000 --- a/capabilities/upload/remove.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !codegen - -package upload - -import "github.com/fil-forge/libforge/capabilities" - -const RemoveCommand = "/upload/remove" - -type RemoveOK = capabilities.Unit - -var Remove = capabilities.MustNew[*RemoveArguments](RemoveCommand) diff --git a/capabilities/upload/shard/list.go b/capabilities/upload/shard/list.go deleted file mode 100644 index 5f759fd..0000000 --- a/capabilities/upload/shard/list.go +++ /dev/null @@ -1,9 +0,0 @@ -//go:build !codegen - -package shard - -import "github.com/fil-forge/libforge/capabilities" - -const ListCommand = "/upload/shard/list" - -var List = capabilities.MustNew[*ListArguments](ListCommand) diff --git a/capabilities/access/cbor_gen.go b/commands/access/cbor_gen.go similarity index 100% rename from capabilities/access/cbor_gen.go rename to commands/access/cbor_gen.go diff --git a/commands/access/claim.go b/commands/access/claim.go new file mode 100644 index 0000000..e671123 --- /dev/null +++ b/commands/access/claim.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package access + +import "github.com/fil-forge/libforge/commands" + +type ClaimArguments = commands.Unit + +// Claim can be invoked by an agent to claim a set of delegations from the +// account. +var Claim = commands.MustParse[*ClaimArguments]("/access/claim") diff --git a/capabilities/access/confirm.go b/commands/access/confirm.go similarity index 86% rename from capabilities/access/confirm.go rename to commands/access/confirm.go index 8d6c464..c07f4f5 100644 --- a/capabilities/access/confirm.go +++ b/commands/access/confirm.go @@ -3,7 +3,7 @@ package access import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/fil-forge/ucantone/errors" ) @@ -16,10 +16,8 @@ type ConfirmOK = ClaimOK // invocation. const ConfirmMetaKey = "accessConfirm" -const ConfirmCommand = "/access/confirm" - // Confirm can be invoked by an agent to confirm an access request. -var Confirm = capabilities.MustNew[*ConfirmArguments](ConfirmCommand) +var Confirm = commands.MustParse[*ConfirmArguments]("/access/confirm") const ( InvalidAccessConfirmSubjectErrorName = "InvalidAccessConfirmSubject" diff --git a/capabilities/access/delegate.go b/commands/access/delegate.go similarity index 58% rename from capabilities/access/delegate.go rename to commands/access/delegate.go index 82e4745..07d9a01 100644 --- a/capabilities/access/delegate.go +++ b/commands/access/delegate.go @@ -2,15 +2,13 @@ package access -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" -const DelegateCommand = "/access/delegate" - -type DelegateOK = capabilities.Unit +type DelegateOK = commands.Unit // Delegate can be invoked by an agent to delegate a set of capabilities that // may be subsequently claimed by another agent. -var Delegate = capabilities.MustNew[*DelegateArguments](DelegateCommand) +var Delegate = commands.MustParse[*DelegateArguments]("/access/delegate") const ( DelegationNotFoundErrorName = "DelegationNotFound" diff --git a/capabilities/access/gen/main.go b/commands/access/gen/main.go similarity index 94% rename from capabilities/access/gen/main.go rename to commands/access/gen/main.go index 914b147..61b8217 100644 --- a/capabilities/access/gen/main.go +++ b/commands/access/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/access" + "github.com/fil-forge/libforge/commands/access" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/access/json_gen.go b/commands/access/json_gen.go similarity index 100% rename from capabilities/access/json_gen.go rename to commands/access/json_gen.go diff --git a/capabilities/access/request.go b/commands/access/request.go similarity index 81% rename from capabilities/access/request.go rename to commands/access/request.go index 45ddf73..fef1330 100644 --- a/capabilities/access/request.go +++ b/commands/access/request.go @@ -2,7 +2,7 @@ package access -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" // RequestFactKey is the key in metadata in any delegation created by a // successful access request. The value is a link back to the `/access/request` @@ -13,7 +13,7 @@ const RequestCommand = "/access/request" // Request can be invoked by an agent to request set of capabilities from the // account. -var Request = capabilities.MustNew[*RequestArguments](RequestCommand) +var Request = commands.MustParse[*RequestArguments](RequestCommand) const ( InvalidAuthorizationAccountErrorName = "InvalidAuthorizationAccount" diff --git a/capabilities/access/types.go b/commands/access/types.go similarity index 100% rename from capabilities/access/types.go rename to commands/access/types.go diff --git a/capabilities/assert/cbor_gen.go b/commands/assert/cbor_gen.go similarity index 98% rename from capabilities/assert/cbor_gen.go rename to commands/assert/cbor_gen.go index c1b6f57..4e6cb13 100644 --- a/capabilities/assert/cbor_gen.go +++ b/commands/assert/cbor_gen.go @@ -10,7 +10,7 @@ import ( "math" "sort" - capabilities "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" @@ -328,7 +328,7 @@ func (t *LocationArguments) MarshalCBOR(w io.Writer) error { return err } - // t.Location ([]capabilities.CborURL) (slice) + // t.Location ([]commands.CborURL) (slice) if len("location") > 8192 { return xerrors.Errorf("Value in field \"location\" was too long") } @@ -450,7 +450,7 @@ func (t *LocationArguments) UnmarshalCBOR(r io.Reader) (err error) { return err } - // t.Location ([]capabilities.CborURL) (slice) + // t.Location ([]commands.CborURL) (slice) case "location": maj, extra, err = cr.ReadHeader() @@ -467,7 +467,7 @@ func (t *LocationArguments) UnmarshalCBOR(r io.Reader) (err error) { } if extra > 0 { - t.Location = make([]capabilities.CborURL, extra) + t.Location = make([]commands.CborURL, extra) } for i := 0; i < int(extra); i++ { diff --git a/capabilities/assert/equals.go b/commands/assert/equals.go similarity index 50% rename from capabilities/assert/equals.go rename to commands/assert/equals.go index a590b47..29d1f8b 100644 --- a/capabilities/assert/equals.go +++ b/commands/assert/equals.go @@ -2,11 +2,11 @@ package assert -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" const EqualsCommand = "/assert/equals" -type EqualsOK = capabilities.Unit +type EqualsOK = commands.Unit // Equals claims data is referred to by another CID e.g CAR CID & Piece CID -var Equals = capabilities.MustNew[*EqualsArguments](EqualsCommand) +var Equals = commands.MustParse[*EqualsArguments](EqualsCommand) diff --git a/capabilities/assert/gen/main.go b/commands/assert/gen/main.go similarity index 94% rename from capabilities/assert/gen/main.go rename to commands/assert/gen/main.go index 0ea385c..483c3f6 100644 --- a/capabilities/assert/gen/main.go +++ b/commands/assert/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/assert" + "github.com/fil-forge/libforge/commands/assert" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/assert/index.go b/commands/assert/index.go similarity index 56% rename from capabilities/assert/index.go rename to commands/assert/index.go index 6a90acf..f39f737 100644 --- a/capabilities/assert/index.go +++ b/commands/assert/index.go @@ -2,12 +2,12 @@ package assert -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" const IndexCommand = "/assert/index" -type IndexOK = capabilities.Unit +type IndexOK = commands.Unit // Index claims that a content graph can be found in blob(s) that are identified // and indexed in the given index CID. -var Index = capabilities.MustNew[*IndexArguments](IndexCommand) +var Index = commands.MustParse[*IndexArguments](IndexCommand) diff --git a/capabilities/assert/json_gen.go b/commands/assert/json_gen.go similarity index 99% rename from capabilities/assert/json_gen.go rename to commands/assert/json_gen.go index 3595d1b..4a9716c 100644 --- a/capabilities/assert/json_gen.go +++ b/commands/assert/json_gen.go @@ -12,7 +12,7 @@ import ( "sort" jsg "github.com/alanshaw/dag-json-gen" - capabilities "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" cid "github.com/ipfs/go-cid" ) @@ -303,7 +303,7 @@ func (t *LocationArguments) MarshalDagJSON(w io.Writer) error { } } - // t.Location ([]capabilities.CborURL) (slice) + // t.Location ([]commands.CborURL) (slice) if len("location") > 8192 { return fmt.Errorf("string in field \"location\" was too long") } @@ -434,7 +434,7 @@ func (t *LocationArguments) UnmarshalDagJSON(r io.Reader) (err error) { } } - // t.Location ([]capabilities.CborURL) (slice) + // t.Location ([]commands.CborURL) (slice) case "location": { @@ -453,7 +453,7 @@ func (t *LocationArguments) UnmarshalDagJSON(r io.Reader) (err error) { } else { for i := 0; i < 8192; i++ { - item := make([]capabilities.CborURL, 1) + item := make([]commands.CborURL, 1) if err := item[0].UnmarshalDagJSON(jr); err != nil { return fmt.Errorf("unmarshaling item[0]: %w", err) diff --git a/commands/assert/location.go b/commands/assert/location.go new file mode 100644 index 0000000..7bcdbc5 --- /dev/null +++ b/commands/assert/location.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package assert + +import "github.com/fil-forge/libforge/commands" + +const LocationCommand = "/assert/location" + +type LocationOK = commands.Unit + +var Location = commands.MustParse[*LocationArguments](LocationCommand) diff --git a/capabilities/assert/types.go b/commands/assert/types.go similarity index 89% rename from capabilities/assert/types.go rename to commands/assert/types.go index 716fbd0..35d6b14 100644 --- a/capabilities/assert/types.go +++ b/commands/assert/types.go @@ -1,7 +1,7 @@ package assert import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/fil-forge/ucantone/did" "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" @@ -21,7 +21,7 @@ type IndexMetadata struct { type LocationArguments struct { Space did.DID `cborgen:"space" dagjsongen:"space"` Content multihash.Multihash `cborgen:"content" dagjsongen:"content"` - Location []capabilities.CborURL `cborgen:"location" dagjsongen:"location"` + Location []commands.CborURL `cborgen:"location" dagjsongen:"location"` Range *Range `cborgen:"range,omitempty" dagjsongen:"range,omitempty"` } diff --git a/commands/bind.go b/commands/bind.go new file mode 100644 index 0000000..ab1fc5e --- /dev/null +++ b/commands/bind.go @@ -0,0 +1,16 @@ +package commands + +import "github.com/fil-forge/ucantone/validator/bindcom" + +// MustParse is like [bindcom.Parse] but panics if the command cannot be +// constructed. It exists for package-level command declarations where the +// command and options are static — any error indicates a programming bug +// (malformed command string, invalid option) and should fail loudly at init +// rather than be silently dropped with `, _`. +func MustParse[A bindcom.Arguments](cmd string) bindcom.Command[A] { + c, err := bindcom.Parse[A](cmd) + if err != nil { + panic(err) + } + return c +} diff --git a/commands/blob/accept.go b/commands/blob/accept.go new file mode 100644 index 0000000..a09a6b4 --- /dev/null +++ b/commands/blob/accept.go @@ -0,0 +1,9 @@ +//go:build !codegen + +package blob + +import "github.com/fil-forge/libforge/commands" + +const AcceptCommand = "/blob/accept" + +var Accept = commands.MustParse[*AcceptArguments](AcceptCommand) diff --git a/commands/blob/add.go b/commands/blob/add.go new file mode 100644 index 0000000..7856b38 --- /dev/null +++ b/commands/blob/add.go @@ -0,0 +1,7 @@ +//go:build !codegen + +package blob + +import "github.com/fil-forge/libforge/commands" + +var Add = commands.MustParse[*AddArguments]("/blob/add") diff --git a/commands/blob/allocate.go b/commands/blob/allocate.go new file mode 100644 index 0000000..5bd10af --- /dev/null +++ b/commands/blob/allocate.go @@ -0,0 +1,9 @@ +//go:build !codegen + +package blob + +import "github.com/fil-forge/libforge/commands" + +const MaxBlobSize = 268_435_456 + +var Allocate = commands.MustParse[*AllocateArguments]("/blob/allocate") diff --git a/capabilities/blob/cbor_gen.go b/commands/blob/cbor_gen.go similarity index 99% rename from capabilities/blob/cbor_gen.go rename to commands/blob/cbor_gen.go index 940120c..0088c2a 100644 --- a/capabilities/blob/cbor_gen.go +++ b/commands/blob/cbor_gen.go @@ -440,7 +440,7 @@ func (t *BlobAddress) MarshalCBOR(w io.Writer) error { return err } - // t.URL (capabilities.CborURL) (struct) + // t.URL (commands.CborURL) (struct) if len("url") > 8192 { return xerrors.Errorf("Value in field \"url\" was too long") } @@ -575,7 +575,7 @@ func (t *BlobAddress) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.URL (capabilities.CborURL) (struct) + // t.URL (commands.CborURL) (struct) case "url": { diff --git a/capabilities/blob/gen/main.go b/commands/blob/gen/main.go similarity index 95% rename from capabilities/blob/gen/main.go rename to commands/blob/gen/main.go index a908bfd..deb3939 100644 --- a/capabilities/blob/gen/main.go +++ b/commands/blob/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/blob" + "github.com/fil-forge/libforge/commands/blob" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/blob/json_gen.go b/commands/blob/json_gen.go similarity index 99% rename from capabilities/blob/json_gen.go rename to commands/blob/json_gen.go index 14acc5d..da899c3 100644 --- a/capabilities/blob/json_gen.go +++ b/commands/blob/json_gen.go @@ -521,7 +521,7 @@ func (t *BlobAddress) MarshalDagJSON(w io.Writer) error { } } - // t.URL (capabilities.CborURL) (struct) + // t.URL (commands.CborURL) (struct) if len("url") > 8192 { return fmt.Errorf("string in field \"url\" was too long") } @@ -640,7 +640,7 @@ func (t *BlobAddress) UnmarshalDagJSON(r io.Reader) (err error) { } } - // t.URL (capabilities.CborURL) (struct) + // t.URL (commands.CborURL) (struct) case "url": if err := t.URL.UnmarshalDagJSON(jr); err != nil { diff --git a/commands/blob/list.go b/commands/blob/list.go new file mode 100644 index 0000000..1e6d343 --- /dev/null +++ b/commands/blob/list.go @@ -0,0 +1,9 @@ +//go:build !codegen + +package blob + +import "github.com/fil-forge/libforge/commands" + +const ListCommand = "/blob/list" + +var List = commands.MustParse[*ListArguments](ListCommand) diff --git a/commands/blob/remove.go b/commands/blob/remove.go new file mode 100644 index 0000000..6a5cd48 --- /dev/null +++ b/commands/blob/remove.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package blob + +import "github.com/fil-forge/libforge/commands" + +const RemoveCommand = "/blob/remove" + +type RemoveOK = commands.Unit + +var Remove = commands.MustParse[*RemoveArguments](RemoveCommand) diff --git a/commands/blob/replica/allocate.go b/commands/blob/replica/allocate.go new file mode 100644 index 0000000..8edbfe8 --- /dev/null +++ b/commands/blob/replica/allocate.go @@ -0,0 +1,7 @@ +//go:build !codegen + +package replica + +import "github.com/fil-forge/libforge/commands" + +var Allocate = commands.MustParse[*AllocateArguments]("/blob/replica/allocate") diff --git a/capabilities/blob/replica/cbor_gen.go b/commands/blob/replica/cbor_gen.go similarity index 100% rename from capabilities/blob/replica/cbor_gen.go rename to commands/blob/replica/cbor_gen.go diff --git a/capabilities/blob/replica/gen/main.go b/commands/blob/replica/gen/main.go similarity index 91% rename from capabilities/blob/replica/gen/main.go rename to commands/blob/replica/gen/main.go index d45ea0c..9fea00f 100644 --- a/capabilities/blob/replica/gen/main.go +++ b/commands/blob/replica/gen/main.go @@ -5,7 +5,7 @@ package main import ( "os" - "github.com/fil-forge/libforge/capabilities/blob/replica" + "github.com/fil-forge/libforge/commands/blob/replica" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/commands/blob/replica/transfer.go b/commands/blob/replica/transfer.go new file mode 100644 index 0000000..8ab0da5 --- /dev/null +++ b/commands/blob/replica/transfer.go @@ -0,0 +1,7 @@ +//go:build !codegen + +package replica + +import "github.com/fil-forge/libforge/commands" + +var Transfer = commands.MustParse[*TransferArguments]("/blob/replica/transfer") diff --git a/capabilities/blob/replica/types.go b/commands/blob/replica/types.go similarity index 100% rename from capabilities/blob/replica/types.go rename to commands/blob/replica/types.go diff --git a/capabilities/blob/replicate.go b/commands/blob/replicate.go similarity index 64% rename from capabilities/blob/replicate.go rename to commands/blob/replicate.go index 0c9960d..eebba2c 100644 --- a/capabilities/blob/replicate.go +++ b/commands/blob/replicate.go @@ -2,13 +2,7 @@ package blob -import ( - "github.com/fil-forge/libforge/capabilities" - "github.com/fil-forge/ucantone/ucan/delegation/policy" - "github.com/fil-forge/ucantone/validator/capability" -) - -const ReplicateCommand = "/blob/replicate" +import "github.com/fil-forge/libforge/commands" // Replicate is a capability that allows an agent to replicate a Blob into a // space identified by did:key in the `with` field. @@ -24,11 +18,4 @@ const ReplicateCommand = "/blob/replicate" // transferred and stored the blob. The number of `/blob/replica/allocate` and // `/blob/replica/transfer` tasks corresponds directly to number of replicas // requested. -var Replicate = capabilities.MustNew[*ReplicateArguments]( - ReplicateCommand, - capability.WithPolicyBuilder( - policy.GreaterThan(".blob.size", 0), - policy.LessThanOrEqual(".blob.size", MaxBlobSize), - policy.GreaterThanOrEqual(".replicas", 1), - ), -) +var Replicate = commands.MustParse[*ReplicateArguments]("/blob/replicate") diff --git a/capabilities/blob/retrieve.go b/commands/blob/retrieve.go similarity index 70% rename from capabilities/blob/retrieve.go rename to commands/blob/retrieve.go index 5c376bc..01309dd 100644 --- a/capabilities/blob/retrieve.go +++ b/commands/blob/retrieve.go @@ -2,7 +2,7 @@ package blob -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" const RetrieveCommand = "/blob/retrieve" @@ -12,6 +12,6 @@ const RetrieveCommand = "/blob/retrieve" // by digest, regardless of which space it was originally stored under. // // For user-facing retrieval that requires an allocation in a specific space -// see `libforge/capabilities/content.Retrieve` (the `/content/retrieve` +// see `libforge/commands/content.Retrieve` (the `/content/retrieve` // capability). -var Retrieve = capabilities.MustNew[*RetrieveArguments](RetrieveCommand) +var Retrieve = commands.MustParse[*RetrieveArguments](RetrieveCommand) diff --git a/capabilities/blob/types.go b/commands/blob/types.go similarity index 97% rename from capabilities/blob/types.go rename to commands/blob/types.go index bc41d59..db530c5 100644 --- a/capabilities/blob/types.go +++ b/commands/blob/types.go @@ -1,7 +1,7 @@ package blob import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/fil-forge/ucantone/ucan/promise" "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" @@ -42,7 +42,7 @@ type AllocateOK struct { } type BlobAddress struct { - URL capabilities.CborURL `cborgen:"url" dagjsongen:"url"` + URL commands.CborURL `cborgen:"url" dagjsongen:"url"` Headers map[string]string `cborgen:"headers" dagjsongen:"headers"` Expires int64 `cborgen:"expires" dagjsongen:"expires"` } diff --git a/capabilities/cbor_gen.go b/commands/cbor_gen.go similarity index 98% rename from capabilities/cbor_gen.go rename to commands/cbor_gen.go index df26246..a2c785e 100644 --- a/capabilities/cbor_gen.go +++ b/commands/cbor_gen.go @@ -2,7 +2,7 @@ // Code generated by github.com/whyrusleeping/cbor-gen. DO NOT EDIT. -package capabilities +package commands import ( "fmt" diff --git a/capabilities/cbor_url.go b/commands/cbor_url.go similarity index 98% rename from capabilities/cbor_url.go rename to commands/cbor_url.go index 5890897..9393899 100644 --- a/capabilities/cbor_url.go +++ b/commands/cbor_url.go @@ -1,4 +1,4 @@ -package capabilities +package commands import ( "bytes" diff --git a/commands/claim/cache.go b/commands/claim/cache.go new file mode 100644 index 0000000..b378bc6 --- /dev/null +++ b/commands/claim/cache.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package claim + +import "github.com/fil-forge/libforge/commands" + +const CacheCommand = "/claim/cache" + +type CacheOK = commands.Unit + +var Cache = commands.MustParse[*CacheArguments](CacheCommand) diff --git a/capabilities/claim/cbor_gen.go b/commands/claim/cbor_gen.go similarity index 100% rename from capabilities/claim/cbor_gen.go rename to commands/claim/cbor_gen.go diff --git a/capabilities/claim/gen/main.go b/commands/claim/gen/main.go similarity index 93% rename from capabilities/claim/gen/main.go rename to commands/claim/gen/main.go index 5d0f208..f9949d3 100644 --- a/capabilities/claim/gen/main.go +++ b/commands/claim/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/claim" + "github.com/fil-forge/libforge/commands/claim" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/claim/json_gen.go b/commands/claim/json_gen.go similarity index 100% rename from capabilities/claim/json_gen.go rename to commands/claim/json_gen.go diff --git a/capabilities/claim/types.go b/commands/claim/types.go similarity index 100% rename from capabilities/claim/types.go rename to commands/claim/types.go diff --git a/capabilities/content/cbor_gen.maps.go b/commands/content/cbor_gen.maps.go similarity index 100% rename from capabilities/content/cbor_gen.maps.go rename to commands/content/cbor_gen.maps.go diff --git a/capabilities/content/cbor_gen.tuples.go b/commands/content/cbor_gen.tuples.go similarity index 100% rename from capabilities/content/cbor_gen.tuples.go rename to commands/content/cbor_gen.tuples.go diff --git a/capabilities/content/gen/main.go b/commands/content/gen/main.go similarity index 95% rename from capabilities/content/gen/main.go rename to commands/content/gen/main.go index c098cac..933561d 100644 --- a/capabilities/content/gen/main.go +++ b/commands/content/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/content" + "github.com/fil-forge/libforge/commands/content" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/content/json_gen.maps.go b/commands/content/json_gen.maps.go similarity index 100% rename from capabilities/content/json_gen.maps.go rename to commands/content/json_gen.maps.go diff --git a/capabilities/content/json_gen.tuples.go b/commands/content/json_gen.tuples.go similarity index 100% rename from capabilities/content/json_gen.tuples.go rename to commands/content/json_gen.tuples.go diff --git a/commands/content/retrieve.go b/commands/content/retrieve.go new file mode 100644 index 0000000..191bba5 --- /dev/null +++ b/commands/content/retrieve.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package content + +import "github.com/fil-forge/libforge/commands" + +const RetrieveCommand = "/content/retrieve" + +type RetrieveOK = commands.Unit + +var Retrieve = commands.MustParse[*RetrieveArguments](RetrieveCommand) diff --git a/capabilities/content/types.go b/commands/content/types.go similarity index 100% rename from capabilities/content/types.go rename to commands/content/types.go diff --git a/capabilities/debug/cbor_gen.go b/commands/debug/cbor_gen.go similarity index 100% rename from capabilities/debug/cbor_gen.go rename to commands/debug/cbor_gen.go diff --git a/commands/debug/echo.go b/commands/debug/echo.go new file mode 100644 index 0000000..4827f25 --- /dev/null +++ b/commands/debug/echo.go @@ -0,0 +1,9 @@ +//go:build !codegen + +package debug + +import "github.com/fil-forge/libforge/commands" + +type EchoOK = EchoArguments + +var Echo = commands.MustParse[*EchoArguments]("/debug/echo") diff --git a/capabilities/debug/gen/main.go b/commands/debug/gen/main.go similarity index 93% rename from capabilities/debug/gen/main.go rename to commands/debug/gen/main.go index 3df1dcd..d94b3e2 100644 --- a/capabilities/debug/gen/main.go +++ b/commands/debug/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/debug" + "github.com/fil-forge/libforge/commands/debug" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/debug/json_gen.go b/commands/debug/json_gen.go similarity index 100% rename from capabilities/debug/json_gen.go rename to commands/debug/json_gen.go diff --git a/capabilities/debug/types.go b/commands/debug/types.go similarity index 100% rename from capabilities/debug/types.go rename to commands/debug/types.go diff --git a/commands/gen/main.go b/commands/gen/main.go new file mode 100644 index 0000000..8abff77 --- /dev/null +++ b/commands/gen/main.go @@ -0,0 +1,41 @@ +//go:generate go run -tags codegen . + +package main + +import ( + "os" + + jsg "github.com/alanshaw/dag-json-gen" + "github.com/fil-forge/libforge/commands" + cbg "github.com/whyrusleeping/cbor-gen" +) + +const buildTag = "//go:build !codegen\n\n" + +func tag(path string) { + data, err := os.ReadFile(path) + if err != nil { + panic(err) + } + if err := os.WriteFile(path, append([]byte(buildTag), data...), 0644); err != nil { + panic(err) + } +} + +func main() { + models := []any{ + commands.Unit{}, + } + const ( + cborFile = "../cbor_gen.go" + jsonFile = "../json_gen.go" + ) + if err := cbg.WriteMapEncodersToFile(cborFile, "commands", models...); err != nil { + panic(err) + } + if err := jsg.WriteMapEncodersToFile(jsonFile, "commands", models...); err != nil { + panic(err) + } + tag(cborFile) + tag(jsonFile) +} diff --git a/capabilities/http/cbor_gen.go b/commands/http/cbor_gen.go similarity index 100% rename from capabilities/http/cbor_gen.go rename to commands/http/cbor_gen.go diff --git a/capabilities/http/gen/main.go b/commands/http/gen/main.go similarity index 93% rename from capabilities/http/gen/main.go rename to commands/http/gen/main.go index 076badb..b12a0a4 100644 --- a/capabilities/http/gen/main.go +++ b/commands/http/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/http" + "github.com/fil-forge/libforge/commands/http" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/http/json_gen.go b/commands/http/json_gen.go similarity index 100% rename from capabilities/http/json_gen.go rename to commands/http/json_gen.go diff --git a/commands/http/put.go b/commands/http/put.go new file mode 100644 index 0000000..7a69ba9 --- /dev/null +++ b/commands/http/put.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package http + +import "github.com/fil-forge/libforge/commands" + +const PutCommand = "/http/put" + +type PutOK = commands.Unit + +var Put = commands.MustParse[*PutArguments](PutCommand) diff --git a/capabilities/http/types.go b/commands/http/types.go similarity index 88% rename from capabilities/http/types.go rename to commands/http/types.go index 700700b..22e2084 100644 --- a/capabilities/http/types.go +++ b/commands/http/types.go @@ -1,7 +1,7 @@ package http import ( - "github.com/fil-forge/libforge/capabilities/blob" + "github.com/fil-forge/libforge/commands/blob" "github.com/fil-forge/ucantone/ucan/promise" ) diff --git a/capabilities/index/add.go b/commands/index/add.go similarity index 65% rename from capabilities/index/add.go rename to commands/index/add.go index c685ad9..196c434 100644 --- a/capabilities/index/add.go +++ b/commands/index/add.go @@ -3,15 +3,15 @@ package index import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/fil-forge/ucantone/errors" ) const AddCommand = "/index/add" -type AddOK = capabilities.Unit +type AddOK = commands.Unit -var Add = capabilities.MustNew[*AddArguments](AddCommand) +var Add = commands.MustParse[*AddArguments](AddCommand) const IndexNotFoundErrorName = "IndexNotFound" diff --git a/capabilities/index/cbor_gen.go b/commands/index/cbor_gen.go similarity index 100% rename from capabilities/index/cbor_gen.go rename to commands/index/cbor_gen.go diff --git a/capabilities/index/gen/main.go b/commands/index/gen/main.go similarity index 93% rename from capabilities/index/gen/main.go rename to commands/index/gen/main.go index d1e7985..a44b1e9 100644 --- a/capabilities/index/gen/main.go +++ b/commands/index/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/index" + "github.com/fil-forge/libforge/commands/index" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/index/json_gen.go b/commands/index/json_gen.go similarity index 100% rename from capabilities/index/json_gen.go rename to commands/index/json_gen.go diff --git a/capabilities/index/types.go b/commands/index/types.go similarity index 100% rename from capabilities/index/types.go rename to commands/index/types.go diff --git a/capabilities/json_gen.go b/commands/json_gen.go similarity index 98% rename from capabilities/json_gen.go rename to commands/json_gen.go index 71a7946..e2b0bbb 100644 --- a/capabilities/json_gen.go +++ b/commands/json_gen.go @@ -2,7 +2,7 @@ // Code generated by github.com/alanshaw/dag-json-gen. DO NOT EDIT. -package capabilities +package commands import ( "errors" diff --git a/capabilities/provider/add.go b/commands/provider/add.go similarity index 77% rename from capabilities/provider/add.go rename to commands/provider/add.go index 8924761..9f7097d 100644 --- a/capabilities/provider/add.go +++ b/commands/provider/add.go @@ -3,13 +3,13 @@ package provider import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/fil-forge/ucantone/errors" ) const AddCommand = "/provider/add" -var Add = capabilities.MustNew[*AddArguments](AddCommand) +var Add = commands.MustParse[*AddArguments](AddCommand) const ( InvalidAccountErrorName = "InvalidAccount" diff --git a/capabilities/provider/cbor_gen.go b/commands/provider/cbor_gen.go similarity index 100% rename from capabilities/provider/cbor_gen.go rename to commands/provider/cbor_gen.go diff --git a/capabilities/provider/gen/main.go b/commands/provider/gen/main.go similarity index 93% rename from capabilities/provider/gen/main.go rename to commands/provider/gen/main.go index f528ab8..201f6f6 100644 --- a/capabilities/provider/gen/main.go +++ b/commands/provider/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/provider" + "github.com/fil-forge/libforge/commands/provider" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/provider/json_gen.go b/commands/provider/json_gen.go similarity index 100% rename from capabilities/provider/json_gen.go rename to commands/provider/json_gen.go diff --git a/capabilities/provider/types.go b/commands/provider/types.go similarity index 100% rename from capabilities/provider/types.go rename to commands/provider/types.go diff --git a/capabilities/space/cbor_gen.go b/commands/space/cbor_gen.go similarity index 100% rename from capabilities/space/cbor_gen.go rename to commands/space/cbor_gen.go diff --git a/capabilities/space/egress/cbor_gen.go b/commands/space/egress/cbor_gen.go similarity index 97% rename from capabilities/space/egress/cbor_gen.go rename to commands/space/egress/cbor_gen.go index c18e3a3..3dde9ff 100644 --- a/capabilities/space/egress/cbor_gen.go +++ b/commands/space/egress/cbor_gen.go @@ -32,7 +32,7 @@ func (t *TrackArguments) MarshalCBOR(w io.Writer) error { return err } - // t.Endpoint (capabilities.CborURL) (struct) + // t.Endpoint (commands.CborURL) (struct) if len("endpoint") > 8192 { return xerrors.Errorf("Value in field \"endpoint\" was too long") } @@ -108,7 +108,7 @@ func (t *TrackArguments) UnmarshalCBOR(r io.Reader) (err error) { } switch string(nameBuf[:nameLen]) { - // t.Endpoint (capabilities.CborURL) (struct) + // t.Endpoint (commands.CborURL) (struct) case "endpoint": { diff --git a/capabilities/space/egress/gen/main.go b/commands/space/egress/gen/main.go similarity index 92% rename from capabilities/space/egress/gen/main.go rename to commands/space/egress/gen/main.go index 8fd7916..ef7ebe0 100644 --- a/capabilities/space/egress/gen/main.go +++ b/commands/space/egress/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/space/egress" + "github.com/fil-forge/libforge/commands/space/egress" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/space/egress/json_gen.go b/commands/space/egress/json_gen.go similarity index 98% rename from capabilities/space/egress/json_gen.go rename to commands/space/egress/json_gen.go index 4c682e3..fd49e62 100644 --- a/capabilities/space/egress/json_gen.go +++ b/commands/space/egress/json_gen.go @@ -31,7 +31,7 @@ func (t *TrackArguments) MarshalDagJSON(w io.Writer) error { } written := 0 - // t.Endpoint (capabilities.CborURL) (struct) + // t.Endpoint (commands.CborURL) (struct) if len("endpoint") > 8192 { return fmt.Errorf("string in field \"endpoint\" was too long") } @@ -106,7 +106,7 @@ func (t *TrackArguments) UnmarshalDagJSON(r io.Reader) (err error) { } switch name { - // t.Endpoint (capabilities.CborURL) (struct) + // t.Endpoint (commands.CborURL) (struct) case "endpoint": if err := t.Endpoint.UnmarshalDagJSON(jr); err != nil { diff --git a/capabilities/space/egress/track.go b/commands/space/egress/track.go similarity index 77% rename from capabilities/space/egress/track.go rename to commands/space/egress/track.go index 416f3f2..a5bb8a5 100644 --- a/capabilities/space/egress/track.go +++ b/commands/space/egress/track.go @@ -2,7 +2,7 @@ package egress -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" const TrackCommand = "/space/egress/track" @@ -11,4 +11,4 @@ const TrackCommand = "/space/egress/track" // `/content/retrieve` receipts. The tracking service responds by forking // a `/space/egress/consolidate` sub-invocation onto the receipt's // effects; the typed OK return is empty. -var Track = capabilities.MustNew[*TrackArguments](TrackCommand) +var Track = commands.MustParse[*TrackArguments](TrackCommand) diff --git a/capabilities/space/egress/types.go b/commands/space/egress/types.go similarity index 87% rename from capabilities/space/egress/types.go rename to commands/space/egress/types.go index 626f7e9..10799e9 100644 --- a/capabilities/space/egress/types.go +++ b/commands/space/egress/types.go @@ -1,7 +1,7 @@ package egress import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/ipfs/go-cid" ) @@ -13,7 +13,7 @@ import ( // should fetch that archive from. type TrackArguments struct { Receipts cid.Cid `cborgen:"receipts" dagjsongen:"receipts"` - Endpoint capabilities.CborURL `cborgen:"endpoint" dagjsongen:"endpoint"` + Endpoint commands.CborURL `cborgen:"endpoint" dagjsongen:"endpoint"` } // TrackOK is the success return for `/space/egress/track`. The tracking diff --git a/capabilities/space/gen/main.go b/commands/space/gen/main.go similarity index 93% rename from capabilities/space/gen/main.go rename to commands/space/gen/main.go index 9945ab0..2b6a5f5 100644 --- a/capabilities/space/gen/main.go +++ b/commands/space/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/space" + "github.com/fil-forge/libforge/commands/space" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/commands/space/info.go b/commands/space/info.go new file mode 100644 index 0000000..c7c4fc8 --- /dev/null +++ b/commands/space/info.go @@ -0,0 +1,13 @@ +//go:build !codegen + +package space + +import "github.com/fil-forge/libforge/commands" + +const InfoCommand = "/space/info" + +type InfoArguments = commands.Unit + +var Info = commands.MustParse[*InfoArguments](InfoCommand) + +const UnknownSpaceErrorName = "UnknownSpace" diff --git a/capabilities/space/json_gen.go b/commands/space/json_gen.go similarity index 100% rename from capabilities/space/json_gen.go rename to commands/space/json_gen.go diff --git a/capabilities/space/types.go b/commands/space/types.go similarity index 100% rename from capabilities/space/types.go rename to commands/space/types.go diff --git a/capabilities/types.go b/commands/types.go similarity index 78% rename from capabilities/types.go rename to commands/types.go index f2b0b15..4dded32 100644 --- a/capabilities/types.go +++ b/commands/types.go @@ -1,7 +1,7 @@ -// Package capabilities defines UCAN capabilities used across the forge +// Package commands defines UCAN commands used across the forge // stack. Each operation lives in a subpackage (e.g. blob, upload, pdp); // this top-level package holds shared wire types and helpers. -package capabilities +package commands // Unit is the empty wire type returned by any capability whose receipt // carries no payload (e.g. /upload/remove, /claim/cache). It encodes as diff --git a/capabilities/ucan/attest/cbor_gen.go b/commands/ucan/attest/cbor_gen.go similarity index 100% rename from capabilities/ucan/attest/cbor_gen.go rename to commands/ucan/attest/cbor_gen.go diff --git a/capabilities/ucan/attest/gen/main.go b/commands/ucan/attest/gen/main.go similarity index 92% rename from capabilities/ucan/attest/gen/main.go rename to commands/ucan/attest/gen/main.go index a318354..7d10b81 100644 --- a/capabilities/ucan/attest/gen/main.go +++ b/commands/ucan/attest/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/ucan/attest" + "github.com/fil-forge/libforge/commands/ucan/attest" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/ucan/attest/json_gen.go b/commands/ucan/attest/json_gen.go similarity index 100% rename from capabilities/ucan/attest/json_gen.go rename to commands/ucan/attest/json_gen.go diff --git a/capabilities/ucan/attest/proof.go b/commands/ucan/attest/proof.go similarity index 60% rename from capabilities/ucan/attest/proof.go rename to commands/ucan/attest/proof.go index ef22143..b0d44fc 100644 --- a/capabilities/ucan/attest/proof.go +++ b/commands/ucan/attest/proof.go @@ -2,12 +2,12 @@ package attest -import "github.com/fil-forge/libforge/capabilities" +import "github.com/fil-forge/libforge/commands" const ProofCommand = "/ucan/attest/proof" -type ProofOK = capabilities.Unit +type ProofOK = commands.Unit // Issued by a trusted authority (usually the one handling invocation) that // attests a specific UCAN delegation has been considered authentic. -var Proof = capabilities.MustNew[*ProofArguments](ProofCommand) +var Proof = commands.MustParse[*ProofArguments](ProofCommand) diff --git a/capabilities/ucan/attest/types.go b/commands/ucan/attest/types.go similarity index 100% rename from capabilities/ucan/attest/types.go rename to commands/ucan/attest/types.go diff --git a/capabilities/ucan/cbor_gen.go b/commands/ucan/cbor_gen.go similarity index 100% rename from capabilities/ucan/cbor_gen.go rename to commands/ucan/cbor_gen.go diff --git a/capabilities/ucan/conclude.go b/commands/ucan/conclude.go similarity index 67% rename from capabilities/ucan/conclude.go rename to commands/ucan/conclude.go index 918556d..ee5e5a7 100644 --- a/capabilities/ucan/conclude.go +++ b/commands/ucan/conclude.go @@ -3,15 +3,15 @@ package ucan import ( - "github.com/fil-forge/libforge/capabilities" + "github.com/fil-forge/libforge/commands" "github.com/fil-forge/ucantone/errors" ) const ConcludeCommand = "/ucan/conclude" -type ConcludeOK = capabilities.Unit +type ConcludeOK = commands.Unit -var Conclude = capabilities.MustNew[*ConcludeArguments](ConcludeCommand) +var Conclude = commands.MustParse[*ConcludeArguments](ConcludeCommand) const ConclusionReceiptNotFoundErrorName = "ConclusionReceiptNotFound" diff --git a/capabilities/ucan/gen/main.go b/commands/ucan/gen/main.go similarity index 93% rename from capabilities/ucan/gen/main.go rename to commands/ucan/gen/main.go index 68cd6f0..6d507c4 100644 --- a/capabilities/ucan/gen/main.go +++ b/commands/ucan/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/ucan" + "github.com/fil-forge/libforge/commands/ucan" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/ucan/json_gen.go b/commands/ucan/json_gen.go similarity index 100% rename from capabilities/ucan/json_gen.go rename to commands/ucan/json_gen.go diff --git a/capabilities/ucan/types.go b/commands/ucan/types.go similarity index 100% rename from capabilities/ucan/types.go rename to commands/ucan/types.go diff --git a/commands/upload/add.go b/commands/upload/add.go new file mode 100644 index 0000000..ace4119 --- /dev/null +++ b/commands/upload/add.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package upload + +import "github.com/fil-forge/libforge/commands" + +const AddCommand = "/upload/add" + +type AddOK = commands.Unit + +var Add = commands.MustParse[*AddArguments](AddCommand) diff --git a/capabilities/upload/cbor_gen.go b/commands/upload/cbor_gen.go similarity index 100% rename from capabilities/upload/cbor_gen.go rename to commands/upload/cbor_gen.go diff --git a/capabilities/upload/gen/main.go b/commands/upload/gen/main.go similarity index 94% rename from capabilities/upload/gen/main.go rename to commands/upload/gen/main.go index 1539992..bbe1113 100644 --- a/capabilities/upload/gen/main.go +++ b/commands/upload/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/upload" + "github.com/fil-forge/libforge/commands/upload" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/upload/json_gen.go b/commands/upload/json_gen.go similarity index 100% rename from capabilities/upload/json_gen.go rename to commands/upload/json_gen.go diff --git a/commands/upload/list.go b/commands/upload/list.go new file mode 100644 index 0000000..caea5f7 --- /dev/null +++ b/commands/upload/list.go @@ -0,0 +1,9 @@ +//go:build !codegen + +package upload + +import "github.com/fil-forge/libforge/commands" + +const ListCommand = "/upload/list" + +var List = commands.MustParse[*ListArguments](ListCommand) diff --git a/commands/upload/remove.go b/commands/upload/remove.go new file mode 100644 index 0000000..6e7b0d9 --- /dev/null +++ b/commands/upload/remove.go @@ -0,0 +1,11 @@ +//go:build !codegen + +package upload + +import "github.com/fil-forge/libforge/commands" + +const RemoveCommand = "/upload/remove" + +type RemoveOK = commands.Unit + +var Remove = commands.MustParse[*RemoveArguments](RemoveCommand) diff --git a/capabilities/upload/shard/cbor_gen.go b/commands/upload/shard/cbor_gen.go similarity index 100% rename from capabilities/upload/shard/cbor_gen.go rename to commands/upload/shard/cbor_gen.go diff --git a/capabilities/upload/shard/gen/main.go b/commands/upload/shard/gen/main.go similarity index 92% rename from capabilities/upload/shard/gen/main.go rename to commands/upload/shard/gen/main.go index 767eccc..cc1e337 100644 --- a/capabilities/upload/shard/gen/main.go +++ b/commands/upload/shard/gen/main.go @@ -6,7 +6,7 @@ import ( "os" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/capabilities/upload/shard" + "github.com/fil-forge/libforge/commands/upload/shard" cbg "github.com/whyrusleeping/cbor-gen" ) diff --git a/capabilities/upload/shard/json_gen.go b/commands/upload/shard/json_gen.go similarity index 100% rename from capabilities/upload/shard/json_gen.go rename to commands/upload/shard/json_gen.go diff --git a/commands/upload/shard/list.go b/commands/upload/shard/list.go new file mode 100644 index 0000000..83c094f --- /dev/null +++ b/commands/upload/shard/list.go @@ -0,0 +1,9 @@ +//go:build !codegen + +package shard + +import "github.com/fil-forge/libforge/commands" + +const ListCommand = "/upload/shard/list" + +var List = commands.MustParse[*ListArguments](ListCommand) diff --git a/capabilities/upload/shard/types.go b/commands/upload/shard/types.go similarity index 100% rename from capabilities/upload/shard/types.go rename to commands/upload/shard/types.go diff --git a/capabilities/upload/types.go b/commands/upload/types.go similarity index 100% rename from capabilities/upload/types.go rename to commands/upload/types.go diff --git a/go.mod b/go.mod index d65d9bb..97e041d 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.25.3 require ( github.com/alanshaw/dag-json-gen v0.0.5 github.com/fil-forge/automobile v0.0.1 - github.com/fil-forge/ucantone v0.0.0-20260514184915-8bebe15b0096 + github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4 github.com/gobwas/glob v0.2.3 github.com/ipfs/go-cid v0.6.1 github.com/ipfs/go-log/v2 v2.9.1 @@ -28,6 +28,8 @@ require ( github.com/multiformats/go-varint v0.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect + gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect + gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.1 // indirect golang.org/x/crypto v0.50.0 // indirect diff --git a/go.sum b/go.sum index 6d728cc..d846b36 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fil-forge/automobile v0.0.1 h1:9xB3yc4l5b9EdRJSJcNwudgBFNHoMPEAdcb7GfobLhA= github.com/fil-forge/automobile v0.0.1/go.mod h1:TsO7jlO8ykJZY5tF8j4GsUcu3F02lEzxO7ULoB61hRA= -github.com/fil-forge/ucantone v0.0.0-20260514184915-8bebe15b0096 h1:T/JkfzRNu4/9OnqgggVWbn+OXs/y12xDSVEen0NS7EY= -github.com/fil-forge/ucantone v0.0.0-20260514184915-8bebe15b0096/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= +github.com/fil-forge/ucantone v0.0.0-20260518190923-2076d2009917 h1:U8M/uecPIORTh2rWlNXvyEI7R3bfBQShB3BtpZfMmOo= +github.com/fil-forge/ucantone v0.0.0-20260518190923-2076d2009917/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= +github.com/fil-forge/ucantone v0.0.0-20260519121626-2fdcb14e364e h1:BN9q/ncbcpk7p8vRk7IrRA/q5NF+3Yj5Xm4xIJVbWmU= +github.com/fil-forge/ucantone v0.0.0-20260519121626-2fdcb14e364e/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= +github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4 h1:Bxmm9l6RE+68luYvekbnmTe7+1epRPZHnSagcMtdvyY= +github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/ipfs/go-cid v0.6.1 h1:T5TnNb08+ueovG76Z5gx1L4Y7QOaGTXHg1F6raWFxIc= diff --git a/ucan/attestations.go b/ucan/attestations.go index 15ddf48..834c7d9 100644 --- a/ucan/attestations.go +++ b/ucan/attestations.go @@ -6,7 +6,7 @@ import ( "fmt" "iter" - "github.com/fil-forge/libforge/capabilities/ucan/attest" + "github.com/fil-forge/libforge/commands/ucan/attest" "github.com/fil-forge/ucantone/did" "github.com/fil-forge/ucantone/ucan" "github.com/fil-forge/ucantone/varsig/algorithm/nonstandard" diff --git a/ucan/attestations_test.go b/ucan/attestations_test.go index 66d777b..0d7aa08 100644 --- a/ucan/attestations_test.go +++ b/ucan/attestations_test.go @@ -6,7 +6,7 @@ import ( "iter" "testing" - "github.com/fil-forge/libforge/capabilities/ucan/attest" + "github.com/fil-forge/libforge/commands/ucan/attest" "github.com/fil-forge/libforge/didmailto" "github.com/fil-forge/libforge/testutil" ucanlib "github.com/fil-forge/libforge/ucan" diff --git a/ucan/proof_store_test.go b/ucan/proof_store_test.go index 25d2ce5..0f43d4d 100644 --- a/ucan/proof_store_test.go +++ b/ucan/proof_store_test.go @@ -3,7 +3,7 @@ package ucanlib_test import ( "testing" - "github.com/fil-forge/libforge/capabilities/ucan/attest" + "github.com/fil-forge/libforge/commands/ucan/attest" "github.com/fil-forge/libforge/didmailto" "github.com/fil-forge/libforge/testutil" ucanlib "github.com/fil-forge/libforge/ucan" diff --git a/ucan/retrieval/client_test.go b/ucan/retrieval/client_test.go index d408121..41a3cda 100644 --- a/ucan/retrieval/client_test.go +++ b/ucan/retrieval/client_test.go @@ -27,7 +27,7 @@ func startTestServer(t *testing.T, handler execution.HandlerFunc) (*url.URL, pri t.Helper() service := testutil.RandomSigner(t) s := retrieval.NewServer(service) - s.Handle(contentRetrieveCapability, handler) + s.Handle(ucan.Command(contentRetrieve), handler) httpServer := httptest.NewServer(s) t.Cleanup(httpServer.Close) u, err := url.Parse(httpServer.URL) @@ -55,7 +55,7 @@ func TestClient(t *testing.T) { client, err := retrieval.NewClient(serviceURL) require.NoError(t, err) - inv, err := contentRetrieveCapability.Invoke( + inv, err := contentRetrieve.Invoke( alice, alice.DID(), datamodel.Map{}, @@ -104,7 +104,7 @@ func TestClient(t *testing.T) { require.NoError(t, err) for range 2 { - inv, err := contentRetrieveCapability.Invoke( + inv, err := contentRetrieve.Invoke( alice, alice.DID(), datamodel.Map{}, @@ -129,7 +129,7 @@ func TestClient(t *testing.T) { client, err := retrieval.NewClient(serviceURL, retrieval.WithEventListener(listener)) require.NoError(t, err) - inv, err := contentRetrieveCapability.Invoke( + inv, err := contentRetrieve.Invoke( alice, alice.DID(), datamodel.Map{}, @@ -160,7 +160,7 @@ func TestClient(t *testing.T) { client, err := retrieval.NewClient(serviceURL, retrieval.WithHTTPClient(httpClient)) require.NoError(t, err) - inv, err := contentRetrieveCapability.Invoke( + inv, err := contentRetrieve.Invoke( alice, alice.DID(), datamodel.Map{}, diff --git a/ucan/retrieval/server_test.go b/ucan/retrieval/server_test.go index 54894dd..a6ce58e 100644 --- a/ucan/retrieval/server_test.go +++ b/ucan/retrieval/server_test.go @@ -12,13 +12,14 @@ import ( "github.com/fil-forge/ucantone/execution" "github.com/fil-forge/ucantone/ipld/datamodel" "github.com/fil-forge/ucantone/testutil" + "github.com/fil-forge/ucantone/ucan" "github.com/fil-forge/ucantone/ucan/container" "github.com/fil-forge/ucantone/ucan/invocation" - "github.com/fil-forge/ucantone/validator/capability" + "github.com/fil-forge/ucantone/validator/bindcom" "github.com/stretchr/testify/require" ) -var contentRetrieveCapability, _ = capability.New("/content/retrieve") +var contentRetrieve, _ = bindcom.Parse[datamodel.Map]("/content/retrieve") func TestServer(t *testing.T) { service := testutil.RandomSigner(t) @@ -35,7 +36,7 @@ func TestServer(t *testing.T) { ) s := retrieval.NewServer(service) - s.Handle(contentRetrieveCapability, func(req execution.Request, res execution.Response) error { + s.Handle(ucan.Command(contentRetrieve), func(req execution.Request, res execution.Response) error { hcReq, ok := req.Metadata().(*retrieval.HTTPHeaderRequestContainer) require.True(t, ok, "expected HTTPHeaderRequestContainer as request metadata") capturedMethod = hcReq.Method @@ -59,7 +60,7 @@ func TestServer(t *testing.T) { httpServer := httptest.NewServer(s) t.Cleanup(httpServer.Close) - inv, err := contentRetrieveCapability.Invoke( + inv, err := contentRetrieve.Invoke( alice, alice.DID(), datamodel.Map{}, From 330226bb2da037e26b4ae8c6ca84148847a29304 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 14:08:24 +0100 Subject: [PATCH 2/8] chore: remove unused makefile directive (not needed) --- Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Makefile b/Makefile index 9875cb7..c8d54b9 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,3 @@ gen: go generate ./... - -clean-gen: - find capabilities -path '*/datamodel/cbor_gen*.go' -delete - find capabilities -path '*/datamodel/json_gen*.go' -delete From 4a95fe5ae7535a3c5203e3d871646958cce876e7 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 14:26:03 +0100 Subject: [PATCH 3/8] fix: inline the command strings --- commands/access/request.go | 4 +--- commands/assert/equals.go | 4 +--- commands/assert/index.go | 4 +--- commands/assert/location.go | 4 +--- commands/blob/accept.go | 4 +--- commands/blob/list.go | 4 +--- commands/blob/remove.go | 4 +--- commands/blob/retrieve.go | 4 +--- commands/claim/cache.go | 4 +--- commands/content/retrieve.go | 4 +--- commands/http/put.go | 4 +--- commands/index/add.go | 4 +--- commands/provider/add.go | 4 +--- commands/space/egress/track.go | 4 +--- commands/space/info.go | 4 +--- commands/ucan/attest/proof.go | 4 +--- commands/ucan/conclude.go | 4 +--- commands/upload/add.go | 4 +--- commands/upload/list.go | 4 +--- commands/upload/remove.go | 4 +--- commands/upload/shard/list.go | 4 +--- ucan/attestations.go | 2 +- ucan/attestations_test.go | 2 +- 23 files changed, 23 insertions(+), 65 deletions(-) diff --git a/commands/access/request.go b/commands/access/request.go index fef1330..265fd58 100644 --- a/commands/access/request.go +++ b/commands/access/request.go @@ -9,11 +9,9 @@ import "github.com/fil-forge/libforge/commands" // invocation. const RequestMetaKey = "accessRequest" -const RequestCommand = "/access/request" - // Request can be invoked by an agent to request set of capabilities from the // account. -var Request = commands.MustParse[*RequestArguments](RequestCommand) +var Request = commands.MustParse[*RequestArguments]("/access/request") const ( InvalidAuthorizationAccountErrorName = "InvalidAuthorizationAccount" diff --git a/commands/assert/equals.go b/commands/assert/equals.go index 29d1f8b..cbfcadd 100644 --- a/commands/assert/equals.go +++ b/commands/assert/equals.go @@ -4,9 +4,7 @@ package assert import "github.com/fil-forge/libforge/commands" -const EqualsCommand = "/assert/equals" - type EqualsOK = commands.Unit // Equals claims data is referred to by another CID e.g CAR CID & Piece CID -var Equals = commands.MustParse[*EqualsArguments](EqualsCommand) +var Equals = commands.MustParse[*EqualsArguments]("/assert/equals") diff --git a/commands/assert/index.go b/commands/assert/index.go index f39f737..a0684c5 100644 --- a/commands/assert/index.go +++ b/commands/assert/index.go @@ -4,10 +4,8 @@ package assert import "github.com/fil-forge/libforge/commands" -const IndexCommand = "/assert/index" - type IndexOK = commands.Unit // Index claims that a content graph can be found in blob(s) that are identified // and indexed in the given index CID. -var Index = commands.MustParse[*IndexArguments](IndexCommand) +var Index = commands.MustParse[*IndexArguments]("/assert/index") diff --git a/commands/assert/location.go b/commands/assert/location.go index 7bcdbc5..5e8e27d 100644 --- a/commands/assert/location.go +++ b/commands/assert/location.go @@ -4,8 +4,6 @@ package assert import "github.com/fil-forge/libforge/commands" -const LocationCommand = "/assert/location" - type LocationOK = commands.Unit -var Location = commands.MustParse[*LocationArguments](LocationCommand) +var Location = commands.MustParse[*LocationArguments]("/assert/location") diff --git a/commands/blob/accept.go b/commands/blob/accept.go index a09a6b4..d9f7e26 100644 --- a/commands/blob/accept.go +++ b/commands/blob/accept.go @@ -4,6 +4,4 @@ package blob import "github.com/fil-forge/libforge/commands" -const AcceptCommand = "/blob/accept" - -var Accept = commands.MustParse[*AcceptArguments](AcceptCommand) +var Accept = commands.MustParse[*AcceptArguments]("/blob/accept") diff --git a/commands/blob/list.go b/commands/blob/list.go index 1e6d343..dc2a71d 100644 --- a/commands/blob/list.go +++ b/commands/blob/list.go @@ -4,6 +4,4 @@ package blob import "github.com/fil-forge/libforge/commands" -const ListCommand = "/blob/list" - -var List = commands.MustParse[*ListArguments](ListCommand) +var List = commands.MustParse[*ListArguments]("/blob/list") diff --git a/commands/blob/remove.go b/commands/blob/remove.go index 6a5cd48..6432b01 100644 --- a/commands/blob/remove.go +++ b/commands/blob/remove.go @@ -4,8 +4,6 @@ package blob import "github.com/fil-forge/libforge/commands" -const RemoveCommand = "/blob/remove" - type RemoveOK = commands.Unit -var Remove = commands.MustParse[*RemoveArguments](RemoveCommand) +var Remove = commands.MustParse[*RemoveArguments]("/blob/remove") diff --git a/commands/blob/retrieve.go b/commands/blob/retrieve.go index 01309dd..e6f45e7 100644 --- a/commands/blob/retrieve.go +++ b/commands/blob/retrieve.go @@ -4,8 +4,6 @@ package blob import "github.com/fil-forge/libforge/commands" -const RetrieveCommand = "/blob/retrieve" - // Retrieve is the service-level retrieval capability (e.g. used by the // indexer to fetch content claims from a Piri node). It is NOT space-scoped: // any holder of a valid delegation for `/blob/retrieve` may fetch the blob @@ -14,4 +12,4 @@ const RetrieveCommand = "/blob/retrieve" // For user-facing retrieval that requires an allocation in a specific space // see `libforge/commands/content.Retrieve` (the `/content/retrieve` // capability). -var Retrieve = commands.MustParse[*RetrieveArguments](RetrieveCommand) +var Retrieve = commands.MustParse[*RetrieveArguments]("/blob/retrieve") diff --git a/commands/claim/cache.go b/commands/claim/cache.go index b378bc6..b2539ba 100644 --- a/commands/claim/cache.go +++ b/commands/claim/cache.go @@ -4,8 +4,6 @@ package claim import "github.com/fil-forge/libforge/commands" -const CacheCommand = "/claim/cache" - type CacheOK = commands.Unit -var Cache = commands.MustParse[*CacheArguments](CacheCommand) +var Cache = commands.MustParse[*CacheArguments]("/claim/cache") diff --git a/commands/content/retrieve.go b/commands/content/retrieve.go index 191bba5..aecb622 100644 --- a/commands/content/retrieve.go +++ b/commands/content/retrieve.go @@ -4,8 +4,6 @@ package content import "github.com/fil-forge/libforge/commands" -const RetrieveCommand = "/content/retrieve" - type RetrieveOK = commands.Unit -var Retrieve = commands.MustParse[*RetrieveArguments](RetrieveCommand) +var Retrieve = commands.MustParse[*RetrieveArguments]("/content/retrieve") diff --git a/commands/http/put.go b/commands/http/put.go index 7a69ba9..aff6151 100644 --- a/commands/http/put.go +++ b/commands/http/put.go @@ -4,8 +4,6 @@ package http import "github.com/fil-forge/libforge/commands" -const PutCommand = "/http/put" - type PutOK = commands.Unit -var Put = commands.MustParse[*PutArguments](PutCommand) +var Put = commands.MustParse[*PutArguments]("/http/put") diff --git a/commands/index/add.go b/commands/index/add.go index 196c434..763aedc 100644 --- a/commands/index/add.go +++ b/commands/index/add.go @@ -7,11 +7,9 @@ import ( "github.com/fil-forge/ucantone/errors" ) -const AddCommand = "/index/add" - type AddOK = commands.Unit -var Add = commands.MustParse[*AddArguments](AddCommand) +var Add = commands.MustParse[*AddArguments]("/index/add") const IndexNotFoundErrorName = "IndexNotFound" diff --git a/commands/provider/add.go b/commands/provider/add.go index 9f7097d..ff6bd1b 100644 --- a/commands/provider/add.go +++ b/commands/provider/add.go @@ -7,9 +7,7 @@ import ( "github.com/fil-forge/ucantone/errors" ) -const AddCommand = "/provider/add" - -var Add = commands.MustParse[*AddArguments](AddCommand) +var Add = commands.MustParse[*AddArguments]("/provider/add") const ( InvalidAccountErrorName = "InvalidAccount" diff --git a/commands/space/egress/track.go b/commands/space/egress/track.go index a5bb8a5..3cb2127 100644 --- a/commands/space/egress/track.go +++ b/commands/space/egress/track.go @@ -4,11 +4,9 @@ package egress import "github.com/fil-forge/libforge/commands" -const TrackCommand = "/space/egress/track" - // Track is the capability a storage node invokes to ask the egress // tracking service to record egress accounted for in a batch of // `/content/retrieve` receipts. The tracking service responds by forking // a `/space/egress/consolidate` sub-invocation onto the receipt's // effects; the typed OK return is empty. -var Track = commands.MustParse[*TrackArguments](TrackCommand) +var Track = commands.MustParse[*TrackArguments]("/space/egress/track") diff --git a/commands/space/info.go b/commands/space/info.go index c7c4fc8..c97a3e5 100644 --- a/commands/space/info.go +++ b/commands/space/info.go @@ -4,10 +4,8 @@ package space import "github.com/fil-forge/libforge/commands" -const InfoCommand = "/space/info" - type InfoArguments = commands.Unit -var Info = commands.MustParse[*InfoArguments](InfoCommand) +var Info = commands.MustParse[*InfoArguments]("/space/info") const UnknownSpaceErrorName = "UnknownSpace" diff --git a/commands/ucan/attest/proof.go b/commands/ucan/attest/proof.go index b0d44fc..cf64a8c 100644 --- a/commands/ucan/attest/proof.go +++ b/commands/ucan/attest/proof.go @@ -4,10 +4,8 @@ package attest import "github.com/fil-forge/libforge/commands" -const ProofCommand = "/ucan/attest/proof" - type ProofOK = commands.Unit // Issued by a trusted authority (usually the one handling invocation) that // attests a specific UCAN delegation has been considered authentic. -var Proof = commands.MustParse[*ProofArguments](ProofCommand) +var Proof = commands.MustParse[*ProofArguments]("/ucan/attest/proof") diff --git a/commands/ucan/conclude.go b/commands/ucan/conclude.go index ee5e5a7..2b9b216 100644 --- a/commands/ucan/conclude.go +++ b/commands/ucan/conclude.go @@ -7,11 +7,9 @@ import ( "github.com/fil-forge/ucantone/errors" ) -const ConcludeCommand = "/ucan/conclude" - type ConcludeOK = commands.Unit -var Conclude = commands.MustParse[*ConcludeArguments](ConcludeCommand) +var Conclude = commands.MustParse[*ConcludeArguments]("/ucan/conclude") const ConclusionReceiptNotFoundErrorName = "ConclusionReceiptNotFound" diff --git a/commands/upload/add.go b/commands/upload/add.go index ace4119..59d08b2 100644 --- a/commands/upload/add.go +++ b/commands/upload/add.go @@ -4,8 +4,6 @@ package upload import "github.com/fil-forge/libforge/commands" -const AddCommand = "/upload/add" - type AddOK = commands.Unit -var Add = commands.MustParse[*AddArguments](AddCommand) +var Add = commands.MustParse[*AddArguments]("/upload/add") diff --git a/commands/upload/list.go b/commands/upload/list.go index caea5f7..780da8d 100644 --- a/commands/upload/list.go +++ b/commands/upload/list.go @@ -4,6 +4,4 @@ package upload import "github.com/fil-forge/libforge/commands" -const ListCommand = "/upload/list" - -var List = commands.MustParse[*ListArguments](ListCommand) +var List = commands.MustParse[*ListArguments]("/upload/list") diff --git a/commands/upload/remove.go b/commands/upload/remove.go index 6e7b0d9..875791a 100644 --- a/commands/upload/remove.go +++ b/commands/upload/remove.go @@ -4,8 +4,6 @@ package upload import "github.com/fil-forge/libforge/commands" -const RemoveCommand = "/upload/remove" - type RemoveOK = commands.Unit -var Remove = commands.MustParse[*RemoveArguments](RemoveCommand) +var Remove = commands.MustParse[*RemoveArguments]("/upload/remove") diff --git a/commands/upload/shard/list.go b/commands/upload/shard/list.go index 83c094f..0e9fb9d 100644 --- a/commands/upload/shard/list.go +++ b/commands/upload/shard/list.go @@ -4,6 +4,4 @@ package shard import "github.com/fil-forge/libforge/commands" -const ListCommand = "/upload/shard/list" - -var List = commands.MustParse[*ListArguments](ListCommand) +var List = commands.MustParse[*ListArguments]("/upload/shard/list") diff --git a/ucan/attestations.go b/ucan/attestations.go index 834c7d9..e64f838 100644 --- a/ucan/attestations.go +++ b/ucan/attestations.go @@ -27,7 +27,7 @@ func ProofAttestations(ctx context.Context, listInvocations InvocationListerFunc continue } var attestation ucan.Invocation - for inv, err := range listInvocations(ctx, proof.Audience(), attest.ProofCommand, authority) { + for inv, err := range listInvocations(ctx, proof.Audience(), ucan.Command(attest.Proof), authority) { if err != nil { return nil, fmt.Errorf("listing invocations for proof signed by %q: %w", proof.Issuer(), err) } diff --git a/ucan/attestations_test.go b/ucan/attestations_test.go index 0d7aa08..a93a96e 100644 --- a/ucan/attestations_test.go +++ b/ucan/attestations_test.go @@ -105,7 +105,7 @@ func TestProofAttestations(t *testing.T) { // Lister should be called with the proof's audience, the /ucan/attest/proof // command, and the authority as subject. require.Equal(t, agent.DID(), calls[0].aud) - require.Equal(t, ucan.Command(attest.ProofCommand), calls[0].cmd) + require.Equal(t, ucan.Command(attest.Proof), calls[0].cmd) require.Equal(t, service.DID(), calls[0].sub) }) From 49f25b16bb790a59e6b6813dec85bb00611244c7 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 14:29:43 +0100 Subject: [PATCH 4/8] chore: regen --- commands/assert/cbor_gen.go | 2 +- commands/assert/json_gen.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/assert/cbor_gen.go b/commands/assert/cbor_gen.go index 4e6cb13..af68fd8 100644 --- a/commands/assert/cbor_gen.go +++ b/commands/assert/cbor_gen.go @@ -10,7 +10,7 @@ import ( "math" "sort" - "github.com/fil-forge/libforge/commands" + commands "github.com/fil-forge/libforge/commands" cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" diff --git a/commands/assert/json_gen.go b/commands/assert/json_gen.go index 4a9716c..efd7d62 100644 --- a/commands/assert/json_gen.go +++ b/commands/assert/json_gen.go @@ -12,7 +12,7 @@ import ( "sort" jsg "github.com/alanshaw/dag-json-gen" - "github.com/fil-forge/libforge/commands" + commands "github.com/fil-forge/libforge/commands" cid "github.com/ipfs/go-cid" ) From 4d5747ca0927dd82d8ffbaf6664e6f988b4309b4 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 14:32:20 +0100 Subject: [PATCH 5/8] chore: appease linter --- commands/assert/types.go | 8 ++++---- commands/blob/types.go | 6 +++--- commands/space/egress/types.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/commands/assert/types.go b/commands/assert/types.go index 35d6b14..bdbed63 100644 --- a/commands/assert/types.go +++ b/commands/assert/types.go @@ -19,10 +19,10 @@ type IndexMetadata struct { } type LocationArguments struct { - Space did.DID `cborgen:"space" dagjsongen:"space"` - Content multihash.Multihash `cborgen:"content" dagjsongen:"content"` - Location []commands.CborURL `cborgen:"location" dagjsongen:"location"` - Range *Range `cborgen:"range,omitempty" dagjsongen:"range,omitempty"` + Space did.DID `cborgen:"space" dagjsongen:"space"` + Content multihash.Multihash `cborgen:"content" dagjsongen:"content"` + Location []commands.CborURL `cborgen:"location" dagjsongen:"location"` + Range *Range `cborgen:"range,omitempty" dagjsongen:"range,omitempty"` } type Range struct { diff --git a/commands/blob/types.go b/commands/blob/types.go index db530c5..3dc5486 100644 --- a/commands/blob/types.go +++ b/commands/blob/types.go @@ -42,9 +42,9 @@ type AllocateOK struct { } type BlobAddress struct { - URL commands.CborURL `cborgen:"url" dagjsongen:"url"` - Headers map[string]string `cborgen:"headers" dagjsongen:"headers"` - Expires int64 `cborgen:"expires" dagjsongen:"expires"` + URL commands.CborURL `cborgen:"url" dagjsongen:"url"` + Headers map[string]string `cborgen:"headers" dagjsongen:"headers"` + Expires int64 `cborgen:"expires" dagjsongen:"expires"` } type ListArguments struct { diff --git a/commands/space/egress/types.go b/commands/space/egress/types.go index 10799e9..3499722 100644 --- a/commands/space/egress/types.go +++ b/commands/space/egress/types.go @@ -12,7 +12,7 @@ import ( // the storage node has staged); Endpoint is the URL the tracking service // should fetch that archive from. type TrackArguments struct { - Receipts cid.Cid `cborgen:"receipts" dagjsongen:"receipts"` + Receipts cid.Cid `cborgen:"receipts" dagjsongen:"receipts"` Endpoint commands.CborURL `cborgen:"endpoint" dagjsongen:"endpoint"` } From 17aab55d46e11b0cb041755734dc5585dd4bea5e Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 16:33:41 +0100 Subject: [PATCH 6/8] chore: mod tidy --- go.sum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/go.sum b/go.sum index d846b36..ce46f6a 100644 --- a/go.sum +++ b/go.sum @@ -4,10 +4,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fil-forge/automobile v0.0.1 h1:9xB3yc4l5b9EdRJSJcNwudgBFNHoMPEAdcb7GfobLhA= github.com/fil-forge/automobile v0.0.1/go.mod h1:TsO7jlO8ykJZY5tF8j4GsUcu3F02lEzxO7ULoB61hRA= -github.com/fil-forge/ucantone v0.0.0-20260518190923-2076d2009917 h1:U8M/uecPIORTh2rWlNXvyEI7R3bfBQShB3BtpZfMmOo= -github.com/fil-forge/ucantone v0.0.0-20260518190923-2076d2009917/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= -github.com/fil-forge/ucantone v0.0.0-20260519121626-2fdcb14e364e h1:BN9q/ncbcpk7p8vRk7IrRA/q5NF+3Yj5Xm4xIJVbWmU= -github.com/fil-forge/ucantone v0.0.0-20260519121626-2fdcb14e364e/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4 h1:Bxmm9l6RE+68luYvekbnmTe7+1epRPZHnSagcMtdvyY= github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= From efe3ae619b5a6d4b430feb6c68bee7c2563dd929 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 17:31:45 +0100 Subject: [PATCH 7/8] fix: also remove the phony --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c8d54b9..fa76d41 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: gen clean-gen +.PHONY: gen gen: go generate ./... From bba71040c69cf8e1a7269a5cf788fedbb1fa31ba Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 19 May 2026 20:35:10 +0100 Subject: [PATCH 8/8] chore: update ucantone --- go.mod | 2 +- go.sum | 4 ++-- ucan/attestations.go | 2 +- ucan/attestations_test.go | 2 +- ucan/retrieval/client_test.go | 2 +- ucan/retrieval/server_test.go | 3 +-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 97e041d..9b346ee 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.25.3 require ( github.com/alanshaw/dag-json-gen v0.0.5 github.com/fil-forge/automobile v0.0.1 - github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4 + github.com/fil-forge/ucantone v0.0.0-20260519193222-ad31490eaa10 github.com/gobwas/glob v0.2.3 github.com/ipfs/go-cid v0.6.1 github.com/ipfs/go-log/v2 v2.9.1 diff --git a/go.sum b/go.sum index ce46f6a..2278b41 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fil-forge/automobile v0.0.1 h1:9xB3yc4l5b9EdRJSJcNwudgBFNHoMPEAdcb7GfobLhA= github.com/fil-forge/automobile v0.0.1/go.mod h1:TsO7jlO8ykJZY5tF8j4GsUcu3F02lEzxO7ULoB61hRA= -github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4 h1:Bxmm9l6RE+68luYvekbnmTe7+1epRPZHnSagcMtdvyY= -github.com/fil-forge/ucantone v0.0.0-20260519122919-0ee8deb17aa4/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= +github.com/fil-forge/ucantone v0.0.0-20260519193222-ad31490eaa10 h1:ApgWAIpXjCYjZw/yDxLn8IA9WrH/ENPRWCWPT/MoCvU= +github.com/fil-forge/ucantone v0.0.0-20260519193222-ad31490eaa10/go.mod h1:vqgVEsy6LEEsY24Zyjxem0vSofj1XTIx29GbV635f+I= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/ipfs/go-cid v0.6.1 h1:T5TnNb08+ueovG76Z5gx1L4Y7QOaGTXHg1F6raWFxIc= diff --git a/ucan/attestations.go b/ucan/attestations.go index e64f838..8eb4665 100644 --- a/ucan/attestations.go +++ b/ucan/attestations.go @@ -27,7 +27,7 @@ func ProofAttestations(ctx context.Context, listInvocations InvocationListerFunc continue } var attestation ucan.Invocation - for inv, err := range listInvocations(ctx, proof.Audience(), ucan.Command(attest.Proof), authority) { + for inv, err := range listInvocations(ctx, proof.Audience(), attest.Proof.Command, authority) { if err != nil { return nil, fmt.Errorf("listing invocations for proof signed by %q: %w", proof.Issuer(), err) } diff --git a/ucan/attestations_test.go b/ucan/attestations_test.go index a93a96e..cec975b 100644 --- a/ucan/attestations_test.go +++ b/ucan/attestations_test.go @@ -105,7 +105,7 @@ func TestProofAttestations(t *testing.T) { // Lister should be called with the proof's audience, the /ucan/attest/proof // command, and the authority as subject. require.Equal(t, agent.DID(), calls[0].aud) - require.Equal(t, ucan.Command(attest.Proof), calls[0].cmd) + require.Equal(t, attest.Proof.Command, calls[0].cmd) require.Equal(t, service.DID(), calls[0].sub) }) diff --git a/ucan/retrieval/client_test.go b/ucan/retrieval/client_test.go index 41a3cda..ef3b3dc 100644 --- a/ucan/retrieval/client_test.go +++ b/ucan/retrieval/client_test.go @@ -27,7 +27,7 @@ func startTestServer(t *testing.T, handler execution.HandlerFunc) (*url.URL, pri t.Helper() service := testutil.RandomSigner(t) s := retrieval.NewServer(service) - s.Handle(ucan.Command(contentRetrieve), handler) + s.Handle(contentRetrieve.Command, handler) httpServer := httptest.NewServer(s) t.Cleanup(httpServer.Close) u, err := url.Parse(httpServer.URL) diff --git a/ucan/retrieval/server_test.go b/ucan/retrieval/server_test.go index a6ce58e..1286883 100644 --- a/ucan/retrieval/server_test.go +++ b/ucan/retrieval/server_test.go @@ -12,7 +12,6 @@ import ( "github.com/fil-forge/ucantone/execution" "github.com/fil-forge/ucantone/ipld/datamodel" "github.com/fil-forge/ucantone/testutil" - "github.com/fil-forge/ucantone/ucan" "github.com/fil-forge/ucantone/ucan/container" "github.com/fil-forge/ucantone/ucan/invocation" "github.com/fil-forge/ucantone/validator/bindcom" @@ -36,7 +35,7 @@ func TestServer(t *testing.T) { ) s := retrieval.NewServer(service) - s.Handle(ucan.Command(contentRetrieve), func(req execution.Request, res execution.Response) error { + s.Handle(contentRetrieve.Command, func(req execution.Request, res execution.Response) error { hcReq, ok := req.Metadata().(*retrieval.HTTPHeaderRequestContainer) require.True(t, ok, "expected HTTPHeaderRequestContainer as request metadata") capturedMethod = hcReq.Method