Skip to content

feat: UCAN 1.0#2

Open
alanshaw wants to merge 23 commits into
mainfrom
ash/feat/ucan1
Open

feat: UCAN 1.0#2
alanshaw wants to merge 23 commits into
mainfrom
ash/feat/ucan1

Conversation

@alanshaw
Copy link
Copy Markdown
Member

Moves the code base to UCAN 1.0, as implemented by https://github.com/fil-forge/ucantone.

Note: Does not implement replication yet.

@alanshaw alanshaw requested review from Peeja and frrist May 11, 2026 09:56
Copy link
Copy Markdown
Member

@frrist frrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting some early comments in, looks great so far! just a lot to review 😅

Comment on lines 19 to 33
func doRegister(cmd *cobra.Command, args []string) error {
c, _, _, id := lib.InitClient(cmd)
c, _, _, _ := lib.InitClient(cmd)

endpoint, err := url.Parse(args[0])
id, err := did.Parse(args[0])
cobra.CheckErr(err)

proof, err := delegation.Parse(args[1])
endpoint, err := url.Parse(args[1])
cobra.CheckErr(err)

_, err = c.AdminProviderRegister(cmd.Context(), id.Signer, endpoint.String(), proof)
_, err = c.AdminProviderRegister(cmd.Context(), id, endpoint.String())
cobra.CheckErr(err)

cmd.Println("Provider registered successfully")
return nil
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove cobra.CheckErr calls here and just return the error to the caller. registerCmd invokes doRegister as a RunE method which expects an error type. The behavior of CheckErr isn't what we want here, I think: https://github.com/spf13/cobra/blob/v1.10.2/cobra.go#L235

More generally, lets really try and limit our usage of cobra.CheckErr to init methods, flag binding, and top level CLI packages.

Comment thread cmd/client/lib/client.go
client.WithServiceURL(fmt.Sprintf("http://%s:%d", cfg.Server.Host, cfg.Server.Port)),
)
endpoint, err := url.Parse(fmt.Sprintf("http://%s:%d", cfg.Server.Host, cfg.Server.Port))
cobra.CheckErr(err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread cmd/client/lib/client.go
Comment thread internal/fx/service/provider.go
Comment thread internal/fx/service/provider.go Outdated
Comment thread pkg/capabilities/admin/provider/datamodel/list.go Outdated
Comment thread pkg/capabilities/admin/provider/weight/datamodel/gen/main.go Outdated
Comment thread pkg/capabilities/admin/provider/weight/set.go Outdated
Comment thread pkg/client/client.go
Comment on lines +44 to +45
if c.signer.DID() != c.uploadServiceID {
return nil, fmt.Errorf("admin operation not permitted: signer DID %s does not match upload service ID %s", c.signer.DID(), c.uploadServiceID)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: Feels like this ought to be a middleware since this is ~ACL of who/what can call these methods.

Comment on lines +28 to +43
fields := []zap.Field{
zap.Stringer("issuer", inv.Issuer().DID()),
zap.Stringer("subject", inv.Subject().DID()),
zap.Stringer("command", inv.Command()),
zap.Any("arguments", inv.Arguments()),
}
if inv.Audience() != nil {
fields = append(fields, zap.Stringer("audience", inv.Audience().DID()))
}
if len(inv.Metadata()) > 0 {
fields = append(fields, zap.Any("metadata", inv.Metadata()))
}
if len(inv.Proofs()) > 0 {
fields = append(fields, zap.Stringers("proofs", inv.Proofs()))
}
log := logger.With(zap.Dict("invocation", fields...))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/uber-go/zap/blob/master/zapcore/marshaler.go#L23-L32 is nice for this type of thing, lets us re-use it across calls.

alanshaw added a commit to fil-forge/libforge that referenced this pull request May 19, 2026
Adds a "proof store" interface and implementation allowing you to create
one from a UCAN container.

The interface is a thin wrapper around the lower level utility functions
for obtaining proof chains (and attestations) for invocations.

Note: this was implemented in fil-forge/sprue#2
originally but I need it also in indexing service.

Renames `capabilities` to `commands` and renames `capabilities.MustNew(...)` to `capabilities.MustParse(...)`.

depends on fil-forge/ucantone#14
@Peeja
Copy link
Copy Markdown
Contributor

Peeja commented May 22, 2026

@alanshaw You might like to pull in b4fc2a0, it makes the tests a little nicer dealing with errors in receipts. I've added a few more and put it in a PR: #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants