Skip to content

feat: privacy-first CLI with human-friendly output#32

Open
grumbach wants to merge 31 commits intoWithAutonomi:mainfrom
grumbach:feat/cli-polish
Open

feat: privacy-first CLI with human-friendly output#32
grumbach wants to merge 31 commits intoWithAutonomi:mainfrom
grumbach:feat/cli-polish

Conversation

@grumbach
Copy link
Copy Markdown
Contributor

@grumbach grumbach commented Apr 10, 2026

Privacy-first CLI with human-friendly output

No logs by default. A decentralized network client must not leak metadata. Users opt in with -v/-vv/-vvv.

Human-friendly output:

$ ant file upload --public photo.jpg
Connecting to network... done
Approving token spend... done
Uploading photo.jpg (2.0 MB)...
Storing public data map... done

Upload complete!
  Address: c2643c773...
  Chunks:  3
  Size:    2.0 MB
  Cost:    0.2500 ANT (gas: 0.000106 ETH)
  Time:    0.2s

Anyone can download this file with:
  ant file download c2643c773...

Re-upload (already stored):

Upload complete!
  Cost:    free (already stored)

Download:

$ ant file download --datamap photo.datamap -o restored.jpg
Connecting to network... done
Downloading from network...
Download complete!
  File: restored.jpg
  Size: 2.0 MB
  Time: 0.1s

JSON (clean piping):

$ ant --json file upload photo.jpg 2>/dev/null
{"datamap":"photo.datamap","mode":"private","chunks":3,"size":2097152,"storage_cost_atto":"250000000000000000","gas_cost_wei":"106000000000000","elapsed_secs":0.2}

Changes

  • -v info, -vv debug, -vvv trace. Default: silent. Replaces --log-level.
  • --evm-network defaults to arbitrum-one (was local which always errored without --devnet-manifest)
  • -b supports comma-separated addresses: -b 1.2.3.4:10000,5.6.7.8:10000
  • Storage cost and gas cost shown after every upload, wired through from EVM receipts
  • Cost shows free (already stored) when chunks already exist on network
  • Files < 3 bytes get a clear error instead of a cryptic self-encryption crash
  • JSON output uses serde structs (not hand-rolled format strings) for safety on all platforms
  • Both JSON cost fields are strings for precision safety (u128 loses precision in JS/Python)
  • --json works globally for both upload and download
  • Progress on stderr, results on stdout (correct for piping)
  • stdout flushed before process::exit
  • Error format uses Display chain (not Debug) to avoid leaking internal details
  • README updated with new output format and examples

Tested locally

12 test cases on a 10-node local devnet: 1-byte file (error), 1KB/1MB/10MB uploads, re-upload (free), public upload, private download with integrity check, JSON upload, JSON download, missing SECRET_KEY error, bad address error, verbose mode.

jacderida and others added 24 commits April 4, 2026 18:36
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Privacy by design: no logs emitted by default. Users opt in with -v.

Verbosity: -v info, -vv debug, -vvv trace. Default: silent.

Human-friendly output with progress on stderr, results on stdout.
JSON mode (--json) suppresses all stderr and outputs valid serde JSON.
Global --json works for both upload and download.
Error format uses Display (not Debug) to avoid leaking internal details.
Stdout flushed before process::exit to prevent lost output.

Removes --log-level flag (replaced by -v).
The old default 'local' required --devnet-manifest, giving users a
confusing error. Production users should not need to specify the network.
- Replace --log-level with -v/--verbose in global flags table
- Update --evm-network default from 'local' to 'arbitrum-one'
- Put production examples first (no --evm-network needed)
- Update upload/download output examples to match new human-friendly format
- Add devnet wallet key and --evm-network local to devnet examples
-b 1.2.3.4:10000,5.6.7.8:10000 now works alongside repeated flags.
Reverts incomplete total_cost change (needs proper ant-core plumbing).
Wires cost data through the upload pipeline:
- batch_pay() now returns gas_cost_wei from the EVM receipt
- batch_upload_chunks() accumulates costs across payment waves
- FileUploadResult carries storage_cost_atto and gas_cost_wei
- CLI displays: 'Cost: 249999999 nano (gas: 0.000106 ETH)'
- JSON output includes both fields

Cost shows 0 when chunks already existed (no payment made).
- Cost now shows '0.2500 ANT' instead of '249999999 nano'
- Re-uploads show 'free (already stored)' instead of '0 (gas: 0 ETH)'
- Files < 3 bytes get a clear error instead of a cryptic self-encryption crash
- Gas shows as ETH with appropriate precision
- gas_cost_wei now String in JSON output (matches storage_cost_atto,
  avoids u128 precision loss in JavaScript/Python JSON parsers)
- Replace unwrap_or_default() with ? on JSON serialization
  (surfaces errors instead of silently emitting empty strings)
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