Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
7ec00c3
feat(node): add the HF read surface and release durability
beardthelion Nov 20, 2026
7fa4fc2
fix(node): pin git-stored model files into the block map
beardthelion Nov 20, 2026
e9c83e8
feat(cli): add twigpine model fetch
beardthelion Nov 20, 2026
e997491
test(node): add the model hosting end-to-end test
beardthelion Nov 20, 2026
1847bfe
docs: document model hosting
beardthelion Nov 20, 2026
9431675
refactor(node): simplify the model read and durability surface
beardthelion Nov 20, 2026
26901c9
fix(node,cli): harden HF denials, durability errors, and anchor valid…
beardthelion Nov 20, 2026
d647cc7
fix(node,cli): accept sha256-length commits on the model surface
beardthelion Nov 20, 2026
d28b926
fix(node,ci): one default release across HF routes, surface fixtures …
beardthelion Nov 21, 2026
3a2feee
Merge remote-tracking branch 'origin/feat/model-hosting-publish' into…
beardthelion Nov 21, 2026
df281f1
style(node): rustfmt the two-branch HF test
beardthelion Nov 21, 2026
d7ab37f
fix(cli): read the Arweave anchor-discovery reply through read_json
beardthelion Nov 21, 2026
3d9606e
Merge origin/feat/model-hosting-publish into feat/model-hosting-read
beardthelion Nov 22, 2026
9f2839e
fix(cli): state the durability behavior in the publish confirm text
beardthelion Nov 23, 2026
32bc4b8
fix(node): lowercase commit pins on HF revision lookup and correct th…
beardthelion Nov 23, 2026
df3799b
fix(cli): accept uppercase hex in model fetch --revision
beardthelion Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,9 @@ ICAPTCHA_URL=https://icaptcha.gitlawb.com

# ── Model hosting (experimental, off by default) ──────────────────────────
# Signed model releases on public repos, with weights stored as
# content-addressed blocks outside git. Off by default; not yet usable end to
# end: this ships the storage and schema only, no publish or read routes yet.
# content-addressed blocks outside git. Enables the publish routes, the
# HF-compatible read surface under /hf, and the IPFS/Arweave durability
# worker. See docs/MODEL-HOSTING.md.
TWIGPINE_MODEL_HOSTING_ENABLED=false
# Per-identity quota for claimed model blocks, in bytes (default 256 GiB).
TWIGPINE_MODEL_QUOTA_BYTES=274877906944
Expand All @@ -499,6 +500,10 @@ TWIGPINE_MODEL_NODE_QUOTA_BYTES=1099511627776
TWIGPINE_MODEL_UNCLAIMED_TTL_SECS=86400
# Base lifetime of an upload session; each accepted block renews it.
TWIGPINE_MODEL_SESSION_TTL_SECS=43200
# Per-IP request limit for the /hf read surface, per hour.
TWIGPINE_HF_READ_RATE_LIMIT=600
# Concurrent model downloads the resolve route will stream.
TWIGPINE_MODEL_DOWNLOAD_PERMITS=16
# Optional cap on the sum of one identity's open upload sessions, in bytes.
# Unset means "use TWIGPINE_MODEL_QUOTA_BYTES".
#TWIGPINE_MODEL_MAX_SESSION_BYTES=
Expand Down
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Important node settings:
| `TWIGPINE_AUTO_SYNC` | Enable automatic sync from known peers. |
| `TWIGPINE_RECONCILIATION_SWEEP` | Enable the hourly durability sweep that re-pins/backstops missing objects (default `true`; disabled when no IPFS/Pinata backend is configured). Public pin repair runs against any configured backend (IPFS, Pinata, or both). Encrypted recovery repair requires local IPFS (`TWIGPINE_IPFS_API`); Pinata-only nodes reconcile public pins only. |
| `TWIGPINE_MAX_PACK_BYTES` | Max git pack body size for smart-HTTP routes. |
| `TWIGPINE_MODEL_HOSTING_ENABLED` | Enable experimental model hosting (signed releases, block storage). Off by default; see `docs/RUN-A-NODE.md` for the quota and block-store knobs. |
| `TWIGPINE_MODEL_HOSTING_ENABLED` | Enable model hosting (signed releases, block storage, HF-compatible reads, independent fetch). Off by default; see [docs/MODEL-HOSTING.md](docs/MODEL-HOSTING.md) for the quota, block-store, and durability knobs. |
| `TWIGPINE_GIT_SERVICE_TIMEOUT_SECS` | Max seconds a served git upload-pack, receive-pack, or `info/refs` advertisement may run before it is aborted (504). Default 600. Also bounds the withheld-blob classification walk (on both the upload-pack serve and receive-pack replication paths) and the push-side pin-candidate discovery (`rev-list` / `cat-file`), each reaped via process-group teardown at the deadline. On the path-scoped upload-pack path the classification walk and the pack serve share ONE deadline, so this value bounds their combined duration rather than granting each stage a full budget: a walk that consumes it leaves the serve nothing and the clone gets a 504. Serving large path-scoped repos may therefore need a higher value than they did when each stage was budgeted separately. Accepted range is 1 to 3153600000 (100 years), since the node derives deadlines from this value and a larger one cannot be represented. |
| `TWIGPINE_GIT_ACQUIRE_TIMEOUT_SECS` | Max seconds the storage-acquisition phase (Tigris HEAD/GET, push advisory-lock) of a served git op may run before the request is shed with a 503, separate from the git-run timeout. The concurrency permit is released on expiry so a stalled backend cannot pin the pool. Default 30. |
| `TWIGPINE_WRITE_LOCK_HOLD_TIMEOUT_SECS` | Max seconds a repo write guard may hold its advisory-lock pool connection, measured from lock-take. One deadline covers every phase under the lock: the under-lock refresh, the caller's under-lock work (for a push, the whole `receive-pack` subprocess, clamped to the lesser of `TWIGPINE_GIT_SERVICE_TIMEOUT_SECS` and the remaining budget), and the release-side upload/unlock. It bounds the lock-pool slot's hold, so a slow push cannot starve other writers for the sum of every per-phase bound. It does not bound the acquire-side lock wait (`TWIGPINE_GIT_ACQUIRE_TIMEOUT_SECS`), post-git outcome bookkeeping, the few seconds the detached reaper holds the session while the git process group dies, or merge writes, which take their guards without this deadline: their git runs unbounded under the lock, and their refresh, publish and unlock keep their own bounds, so a slow merge is never rolled back for overrunning it. Issue writes keep the deadline: an expired one refuses the write before the ref is touched, and a create's git is clamped to it, but a close's git runs unbounded once started. Unset, the effective bound is `TWIGPINE_GIT_SERVICE_TIMEOUT_SECS` itself (600 by default), tracking the git budget; set it only to tighten the hold below the git budget. An explicit value above `TWIGPINE_GIT_SERVICE_TIMEOUT_SECS` is rejected at boot. |
Expand Down
2 changes: 2 additions & 0 deletions crates/twigpine-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ alloy = { version = "1", default-features = false, features = [
] }

ed25519-dalek = { workspace = true }
sha2 = { workspace = true }
hex = { workspace = true }

[dev-dependencies]
mockito = "1"
Expand Down
20 changes: 10 additions & 10 deletions crates/twigpine-cli/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,17 @@ struct Manifest {
/// case it is the most recent and sorts as newest in the merge tie-break. A mined
/// anchor is always `Some(_)` (0 if the gateway reported an unreadable height) so
/// a malformed height can never masquerade as pending/newest.
struct TxRef {
id: String,
height: Option<u64>,
pub(crate) struct TxRef {
pub(crate) id: String,
pub(crate) height: Option<u64>,
}

/// Edges requested per Arweave GraphQL page (`first:` in the discovery query) and
/// the per-page bound enforced when parsing a response. The `first:N` literal in
/// `ARWEAVE_DISCOVERY_QUERY` MUST equal this constant; `query_first_matches_page_size`
/// pins that invariant at test time (the query keeps a literal because `format!`-ing
/// the brace-heavy GraphQL body would be error-prone).
const ARWEAVE_PAGE_SIZE: usize = 100;
pub(crate) const ARWEAVE_PAGE_SIZE: usize = 100;

/// Paginated discovery query: manifests tagged for this repo, newest first, with
/// `pageInfo` for cursor pagination and `block{height}` for the recency tie-break.
Expand All @@ -496,10 +496,10 @@ const ARWEAVE_DISCOVERY_QUERY: &str = r#"query($repo:String!,$cursor:String){tra
/// plus pagination state. `has_next` is `None` when the response omitted
/// `pageInfo` entirely (an older or partial gateway), which the discovery loop
/// treats as terminal but flags when the page was full (possible truncation).
struct TxPage {
refs: Vec<TxRef>,
has_next: Option<bool>,
end_cursor: Option<String>,
pub(crate) struct TxPage {
pub(crate) refs: Vec<TxRef>,
pub(crate) has_next: Option<bool>,
pub(crate) end_cursor: Option<String>,
}

/// Parse one Arweave GraphQL `transactions` page: each edge's tx id and block
Expand All @@ -514,7 +514,7 @@ struct TxPage {
/// (It does not bound the response body itself: `reqwest` buffers and deserializes
/// the whole body before this runs — an unbounded-body concern shared by every
/// gateway read in this file, addressed separately if it ever matters.)
fn parse_tx_page(v: &serde_json::Value) -> TxPage {
pub(crate) fn parse_tx_page(v: &serde_json::Value) -> TxPage {
let txns = v.get("data").and_then(|d| d.get("transactions"));
let refs: Vec<TxRef> = txns
.and_then(|t| t.get("edges"))
Expand Down Expand Up @@ -566,7 +566,7 @@ fn parse_tx_page(v: &serde_json::Value) -> TxPage {

/// Order a block height so that a not-yet-mined anchor (`None`) sorts above any
/// mined one, and mined anchors order by ascending height. Higher rank == newer.
fn height_rank(h: Option<u64>) -> (u8, u64) {
pub(crate) fn height_rank(h: Option<u64>) -> (u8, u64) {
match h {
None => (1, 0), // pending anchor: newest
Some(v) => (0, v), // mined: by block height
Expand Down
43 changes: 43 additions & 0 deletions crates/twigpine-cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//! Library surface of the `twigpine` CLI.
//!
//! `main.rs` is a thin shell over these modules; the lib target exists so the
//! model fetch path is callable in-process (`model::fetch_model`, which the
//! node's end-to-end test drives after the node stops serving) and so command
//! modules can be exercised from integration tests without spawning the
//! binary.
#![recursion_limit = "256"]

pub mod agent;
pub mod bounty;
pub mod cert;
pub mod changelog;
pub mod clone;
pub mod doctor;
pub mod http;
pub mod identity;
pub mod init;
pub mod ipfs_cmd;
pub mod issue;
pub mod mcp;
pub mod mirror;
pub mod model;
pub mod name;
pub mod node;
pub mod node_stake;
pub mod peer;
pub mod pr;
pub mod profile;
pub mod protect;
pub mod quickstart;
pub mod register;
pub mod repo;
mod secret_file;
pub mod star;
pub mod status;
pub mod sync;
pub mod task;
mod text;
pub mod ucan_cmd;
pub mod visibility;
pub mod webhook;
pub mod whoami;
41 changes: 6 additions & 35 deletions crates/twigpine-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,11 @@
use anyhow::Result;
use clap::{Parser, Subcommand};

mod agent;
mod bounty;
mod cert;
mod changelog;
mod clone;
mod doctor;
mod http;
mod identity;
mod init;
mod ipfs_cmd;
mod issue;
mod mcp;
mod mirror;
mod model;
mod name;
mod node;
mod node_stake;
mod peer;
mod pr;
mod profile;
mod protect;
mod quickstart;
mod register;
mod repo;
mod secret_file;
mod star;
mod status;
mod sync;
mod task;
mod text;
mod ucan_cmd;
mod visibility;
mod webhook;
mod whoami;
use twigpine_cli::{
agent, bounty, cert, changelog, clone, doctor, identity, init, ipfs_cmd, issue, mcp, mirror,
model, name, node, peer, pr, profile, protect, quickstart, register, repo, star, status, sync,
task, ucan_cmd, visibility, webhook, whoami,
};

#[derive(Parser)]
#[command(
Expand Down Expand Up @@ -142,7 +113,7 @@ enum Commands {
/// Print your current identity (DID) and optional node info
Whoami(whoami::WhoamiArgs),

/// Publish open-weight model releases
/// Publish and fetch open-weight model releases
Model {
#[command(subcommand)]
cmd: model::ModelCmd,
Expand Down
Loading
Loading