Skip to content

feat: add routing policy commands - #67

Merged
alanshaw merged 2 commits into
mainfrom
ash/feat/add-routing-policy-commands
Sep 8, 2026
Merged

feat: add routing policy commands#67
alanshaw merged 2 commits into
mainfrom
ash/feat/add-routing-policy-commands

Conversation

@alanshaw

@alanshaw alanshaw commented Sep 8, 2026

Copy link
Copy Markdown
Member

Adds:

  • /routing/put - add/update a routing policy
  • /routing/use - instruct a space to use an existing routing policy

refs https://github.com/fil-one/RFC/blob/main/rfcs/2026-08-routing-policies.md

@alanshaw
alanshaw requested review from a team and a lite review from Copilot September 8, 2026 17:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new shared DAG-JSON helpers allow unbounded object/array sizes (missing the generators’ 8192-entry limit), creating an avoidable input-parsing DoS risk and inconsistent decoding behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR introduces a new commands/routing package that defines UCAN commands for routing policies (/routing/put and /routing/use), including types, codecs, and generated CBOR/DAG-JSON encoders/decoders. It also refactors existing hand-written codecs to use a new shared internal codec helper package.

Changes:

  • Add /routing/put and /routing/use command bindings plus routing policy argument types.
  • Add a hand-written codec for DID-keyed CandidateSet, along with generated *_gen.go files and round-trip tests.
  • Introduce commands/internal/codec to share CBOR/DAG-JSON helper primitives and update the S3 hand-written codec to use it.
File summaries
File Description
commands/s3/codec.go Refactors hand-written codecs to use shared internal codec helpers.
commands/routing/use.go Adds /routing/use command binding and stable error-name constants.
commands/routing/types.go Defines routing policy types and command argument structs.
commands/routing/put.go Adds /routing/put command binding and stable error-name constant.
commands/routing/json_gen.go Generated DAG-JSON codec for routing types/arguments.
commands/routing/gen/main.go Code generator entrypoint for routing CBOR/DAG-JSON files.
commands/routing/codec.go Hand-written codec for DID-keyed CandidateSet.
commands/routing/codec_test.go Round-trip tests for routing codecs and wire format.
commands/routing/cbor_gen.go Generated CBOR codec for routing types/arguments.
commands/internal/codec/codec.go New shared CBOR/DAG-JSON helper primitives for hand-written codecs.
Review details

Files not reviewed (2)

  • commands/routing/cbor_gen.go: Generated file
  • commands/routing/json_gen.go: Generated file

Suppressed comments (1)

commands/internal/codec/codec.go:194

  • ReadJSONArray has no maximum element count, unlike dag-json-gen generated decoders which reject arrays larger than 8192 elements. Adding a limit here avoids unbounded allocation/CPU on malicious inputs and keeps behavior consistent with generator defaults.
	for {
		v, err := read()
		if err != nil {
			return nil, err
		}
		out = append(out, v)
		close, err := jr.ReadArrayCloseOrComma()
		if err != nil {
			return nil, err
		}
		if close {
			return out, nil
		}
	}
  • Files reviewed: 8/10 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread commands/internal/codec/codec.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@alanshaw
alanshaw merged commit 249352b into main Sep 8, 2026
8 checks passed
@alanshaw
alanshaw deleted the ash/feat/add-routing-policy-commands branch September 8, 2026 17:53
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.

2 participants