Skip to content

Add redundancy parameter to upload_data for erasure coding #46

Description

@crtahlin

Summary

The gateway supports a redundancy query parameter on POST /api/v1/data/ for erasure coding (values 0-4). Higher redundancy increases data availability at the cost of more storage usage.

What to Implement

1. Gateway Client (gateway_client.py)

Add redundancy parameter to upload_data():

def upload_data(self, data: str, stamp_id: str, content_type: str = "application/json",
                sign: Optional[str] = None, redundancy: Optional[int] = None) -> Dict[str, Any]:

When provided, include as query parameter:

if redundancy is not None:
    params['redundancy'] = redundancy

2. MCP Server (server.py)

Add to upload_data tool schema:

"redundancy": {
    "type": "integer",
    "description": "Erasure coding redundancy level (0-4). Higher values increase data availability and resilience at the cost of more storage. 0 = no redundancy (default), 4 = maximum redundancy.",
    "minimum": 0,
    "maximum": 4
}

3. Validation

Add validation in the handler:

redundancy = arguments.get("redundancy")
if redundancy is not None and not (0 <= redundancy <= 4):
    raise ValueError("Redundancy must be between 0 and 4")

Files to Modify

  • swarm_provenance_mcp/gateway_client.py — add redundancy param
  • swarm_provenance_mcp/server.py — add to tool schema and handler
  • tests/test_gateway_client.py — add tests
  • tests/test_integration.py — add integration tests

Acceptance Criteria

  • upload_data accepts optional redundancy parameter (0-4)
  • Validation rejects values outside 0-4 range
  • Query parameter passed to gateway when set
  • Tool description explains redundancy trade-offs

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgateway-syncSync with swarm_connect gateway changespriority-lowLow priority / nice to have

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions