Skip to content

SDK #20 (draft): dincli/sdk foundation — cid/errors + config/log/web3 + ipfs/contracts#31

Draft
Santiagocetran wants to merge 12 commits into
InfiniteZeroFoundation:feat/din-sdkfrom
Santiagocetran:feat/din-sdk
Draft

SDK #20 (draft): dincli/sdk foundation — cid/errors + config/log/web3 + ipfs/contracts#31
Santiagocetran wants to merge 12 commits into
InfiniteZeroFoundation:feat/din-sdkfrom
Santiagocetran:feat/din-sdk

Conversation

@Santiagocetran

Copy link
Copy Markdown
Collaborator

Draft / WIP — progress on #20, not a merge-ready PR. Opening early per the request to keep feature-branch work visible. Base is feat/din-sdk (not develop).

What this contains

Incremental foundation for the dincli/sdk/ extraction (issue #20), in reviewable slices:

  1. Interface proposal (Developer/design/sdk-interface-proposal.md, v0.3) — the SDK public interface + JSON output conventions; candidate seed for P3-DOC7. Direction confirmed by @umeradl; contract not yet frozen.
  2. Package seeddincli/sdk/{cid,errors}.py + a fresh-subprocess import-boundary test.
  3. Loaders wave 1dincli/sdk/{config,log,web3}.py, then dincli/sdk/{ipfs,contracts}.py, with the original modules (cli/utils.py, cli/log.py, services/ipfs.py, cli/contract_utils.py) reduced to backward-compat re-export shims.

The dincli/sdk package now holds a dependency-clean foundation: cid, errors, config, log, web3, ipfs, contracts. An import-boundary test enforces the core rule — import dincli.sdk pulls in no typer, rich, or dincli.cli.* (CLI depends on SDK, never the reverse).

Verification

  • Unit suite: 95 passed / 1 skipped (76 baseline + 19 new SDK tests).
  • Import-boundary test green across all 7 SDK modules.
  • dincli --help + full-package import smoke pass through the shims (behavior parity).

Scope vs #20 (explicitly partial)

  • ✅ inventory · ✅ JSON conventions defined · ✅ tests + SDK tests · ✅ interface/back-compat documented
  • 🟡 shared-module extraction: IPFS/contracts/config done; wallet/keystore + manifest deferred
  • ⬜ CLI-commands-render-JSON refactor (role-operations step) — not started
  • ⬜ keystones (tx.send, DinSession, SignerProvider, validate_*) — waiting on the frozen SDK contract

So this does not close #20; it's the extraction foundation the rest builds on.

Note on the diff

The base branch feat/din-sdk is currently behind develop, so the file diff includes the develop-sync commits (doc reorg, Filecoin docs, PR #16 wallet follow-ups). The SDK-specific commits are: docs(design) proposal, feat(sdk) seed, and the two refactor(sdk) loader commits.

umeradl and others added 10 commits July 8, 2026 21:05
Documentation/ now describes only what exists in code on develop
(not the live Sepolia deployment), split by audience:
- public/ — participant-facing: setup, cli-reference (was common.md),
  getting-started, manifest, services, roles/, workflows/, guides/
- technical/ — internal: contracts/ (per-contract refs), mechanisms/,
  services/, testing/, upgradable-contracts/, ARCHITECTURE.md
  (placeholder moved from Developer/, lands via P3-DOC1)

Developer/ holds forward-looking material:
- design/ (new) — MECHANISM_DESIGN.md, suggested-staking-mechanism.md
  (moved from Documentation/technical/mechanisms — it specifies planned
  behavior, not current), feasibility-report.md
- proposals/ (was tooling/) — proposals for tools not yet built
- issues/, tasks/, discussion/, rejected-ideas/ unchanged

Also:
- Rewrote both index READMEs with the placement rule and layout
- Added "where does a new doc go" + graduation rule (shipped designs get
  rewritten as current-state in Documentation/technical/, not moved)
- Fixed all repo-internal links to moved files (CLAUDE.md, README.md,
  Developer/*, dincli/docker/node/README.md) and repaired relative links
  inside moved files; fixed dead blob/main GitHub URLs to blob/develop
- Added DevNet 2.0 mechanism design doc (design/MECHANISM_DESIGN.md)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nnect-wallet fixes + OWS spike

Squash of three commits from the PR InfiniteZeroFoundation#16 review branch (634ce1e, 5cd1a9b,
6905808):

- list-accounts source tag: [..] was parsed by Rich as a markup tag and
  dropped; use (..) so imported/created/legacy renders. Docker node README:
  .session is a file, not a directory (review bugs InfiniteZeroFoundation#1, InfiniteZeroFoundation#6).
- connect-wallet: confirm before overwriting an existing named keystore
  (--yes/-y to bypass, mirrors send-eth), never encrypt a new keystore with
  a stale in-memory cached password, and parse .env once per unlock instead
  of per _get_password call (review items InfiniteZeroFoundation#2, InfiniteZeroFoundation#3, InfiniteZeroFoundation#5). Adds 7 tests.
- OWS delegation feasibility spike (Developer/discussion/
  ows-delegation-feasibility.md): hands-on verification that OWS signs an
  EVM tx without exposing the key; scoped-policy delegation remains
  unproven/follow-up. Corrects wallet-setup.md's broken OWS
  export-keystore flow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cherry-picked from PR InfiniteZeroFoundation#28, relocated from Documentation/public/guides/
to Developer/proposals/: this documents research into a storage
provider dincli does not yet integrate (no FOC/filecoin-pin adapter
exists in ipfs.py), so per Developer/README.md's placement rule it
belongs with forward-looking tooling material, not with docs of what
already exists on develop.

Replaces the Storacha guide (PR InfiniteZeroFoundation#26, closed) as the storage
recommendation for Discussion InfiniteZeroFoundation#18: Storacha's infrastructure (console,
API host, and both storacha.link/w3s.link retrieval gateways) is down
as of this research -- Cloudflare Error 1000 on the apex domain,
NXDOMAIN on console/API subdomains, gateways redirecting into the
broken root. Not a frontend-only issue.

Covers Filecoin Pin (the filecoin-pin CLI/library, built on FOC's
Synapse SDK) in the same three-part structure as the Storacha guide:
Web setup, CLI upload/retrieve, and authentication -- wallet keys and
the Session Key delegation model, which turns out to be a much closer
parallel to Storacha's UCAN delegation than raw-key-or-nothing.

Fact-checked against the filecoin-pin GitHub repo directly (README,
CLI source in src/commands/, documentation/retrieval.md and
content-routing-faq.md) rather than docs.filecoin.io, which 404'd on
the CLI walkthrough page during this research. Caught and corrected
one safety-critical error from an earlier research pass: the CLI
defaults to Mainnet (real funds), not Calibration testnet as
initially assumed.
Discussion InfiniteZeroFoundation#18 hands-on testing ruled out both providers this doc
recommended: Lighthouse retrieval is payment-gated (fails the
"readers pay nothing" requirement), and Storacha's infrastructure is
down/deprecated. Point at the new Filecoin Onchain Cloud proposal
(Developer/proposals/filecoin-onchain-cloud.md) instead of leaving a
stale recommendation for the next reader to walk into.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…n guide (relocated)

Manually merged PR InfiniteZeroFoundation#28 by Similoluwa
Abidoye. Content unchanged from the PR except relocation from
Documentation/public/guides/ to Developer/proposals/: FOC/filecoin-pin
is not integrated into dincli (no code changed here, ipfs.py still
only supports env/filebase/custom), so per Developer/README.md's
placement rule this is forward-looking research material, not
documentation of what exists on develop.

Also updates Developer/discussion/add-filecoin-support.md, which
previously recommended Lighthouse and Storacha as the best
Filecoin-backed providers -- both since ruled out by this same
research (Discussion InfiniteZeroFoundation#18) -- so it no longer contradicts the new
proposal doc.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
InfiniteZeroFoundation#20)

v0.3 proposal for the dincli/sdk/ extraction: five design principles, the
JSON envelope contract, DinError taxonomy with reserved tx/rpc subcodes,
non-interactive DinSession/SignerProvider, plan/apply (three-phase for
CID-producing ops) confirmation model, richer TxReceiptInfo, and backward-
compat guarantees. Candidate seed for P3-DOC7. Incorporates two rounds of
code-audit against real call sites.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…niteZeroFoundation#22)

Manually merges the Part 1 deliverable of task_060726_4 from
Similoluwa Abidoye (@Abidoyesimze, PR InfiniteZeroFoundation#22, branch security/foundry-src-review).

The 7 contracts in foundry/src/ are byte-identical between the audit's
pinned commit (d136ff3) and current develop, so the findings and line
references apply as-is to the live contracts.

- Documentation/technical/audits/foundry-src-security-review.md
  (relocated from the PR's Developer/audits/ path)
- foundry/test/SecurityFindings.t.sol — 9 PoC/verification tests, all
  passing (forge test --match-contract SecurityFindingsTest).

Findings: 0 Critical, 4 High, 4 Medium, 8 Low/Informational.
Open follow-ups tracked on PR InfiniteZeroFoundation#22: severity of H-1/H-2 (candidate for
Critical) and a measured spec-scale gas number for H-1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ary test (InfiniteZeroFoundation#20)

First clean-seed extraction for the SDK layer:
- dincli/sdk/cid.py: moved verbatim from services/cid_utils (zero cli deps);
  services/cid_utils.py kept as a back-compat re-export shim (13 importers).
- dincli/sdk/errors.py: DinError hierarchy + reserved tx/rpc subcodes +
  allowlist-oriented sanitize_details (proposal §4/§4a).
- tests/test_sdk_boundary.py: fresh-subprocess import-boundary test enforcing
  'sdk imports no typer/rich/dincli.cli', plus error/sanitizer unit tests.

runtime/ipfs/contracts deferred to the loaders step: they import cli.utils/log
at module load, so moving them now would fail the boundary test until
config/manifest/web3/log are extracted. Unit suite green (76 passed, 1 skipped).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…iteZeroFoundation#20)

Move the dependency-root loader cluster out of dincli/cli into dincli/sdk,
leaving the old paths as re-export shims:
- sdk/config.py: config/env/network/IPFS-config resolution + constants +
  IPFSConfig; console.print -> logger; logging.getLogger("dincli") directly
  (no sdk.log import -> no config<->log cycle).
- sdk/log.py: logger + quiet _read_log_level() bootstrap (no missing-config
  warning at import).
- sdk/web3.py: get_w3 (ConnectionError kept; # TODO(sdk-keystones)).
- cli/utils.py: re-exports placed above the wallet constants they feed;
  wallet/keystore/manifest/tx code stays.
- cli/log.py: re-exports logger + stdlib logging (dincli.cli.context needs both).
Tests: add test_sdk_config.py (17) + test_sdk_web3.py (2); migrate
test_connect_wallet's config-file patch to sdk.config.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…n-seed (InfiniteZeroFoundation#20)

- sdk/ipfs.py: 3-provider upload/retrieve from services/ipfs; imports
  redirected to sdk.config/sdk.log/sdk.cid; progress prints -> logger;
  # TODO(sdk-keystones): IpfsError.
- sdk/contracts.py: ABIs + get_contract_instance; lazy get_w3 from sdk.web3.
- services/ipfs.py, cli/contract_utils.py: re-export shims.
- tests/test_ipfs_config.py: migrate config-file + ipfs-global patches to
  sdk.config / sdk.ipfs (re-export does not redirect a moved fn's globals).

The dincli/sdk package now holds a dependency-clean foundation
(cid, errors, config, log, web3, ipfs, contracts); the import-boundary test
enforces no typer/rich/dincli.cli imports across all of it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Santiagocetran Santiagocetran mentioned this pull request Jul 13, 2026
6 tasks
@umeradl umeradl added the Draft label Jul 13, 2026
Santiagocetran and others added 2 commits July 13, 2026 15:56
… the loader tier (InfiniteZeroFoundation#20)

Move the manifest / din_info functions and ServiceRuntimeContext into
dincli/sdk, leaving the old paths as backward-compat shims:
- sdk/manifest.py: load_din_info, save_din_info, load_cid_services,
  download_manifest, get_model_info, get_manifest, get_manifest_path,
  get_manifest_key, is_ethereum_address; patchable DIN_INFO_PATH /
  CID_SERVICES_PATH constants; logging.getLogger("dincli") directly (no
  sdk.log import -> no cycle). Presentation stripped: cache_manifest's
  negative-id guard -> ValidationError; the info-block printing lifted out
  into a pure get_model_info returning data; the freshness warning ->
  logger.warning.
- sdk/runtime.py: ServiceRuntimeContext + build_service_runtime_context,
  import repointed to sdk.manifest.
- cli/utils.py: re-exports (above the wrapper); cache_manifest is now a thin
  CLI wrapper composing download_manifest + get_model_info + console.print and
  mapping ValidationError -> typer.Exit(1) (main.py has no DinError handler),
  reproducing the original info output verbatim.
- services/runtime.py: re-export shim.

Completes the SDK loader tier (cid, errors, config, log, web3, ipfs,
contracts, manifest, runtime). No sdk<->cli cycle; import-boundary test now
covers manifest+runtime. Tests: +22 (test_sdk_manifest), suite 117 passed /
1 skipped; behavior parity + tests/dincli import integrity verified.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants