Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 17 additions & 17 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ members = [
]

[workspace.package]
version = "0.3.67"
version = "0.3.68"
edition = "2024"
license = "MIT"
repository = "https://github.com/profullstack/c0mpute"
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@c0mpute/desktop",
"productName": "c0mpute",
"desktopName": "c0mpute-desktop.desktop",
"version": "0.3.67",
"version": "0.3.68",
"private": true,
"type": "module",
"description": "c0mpute desktop: chat, agent with your MCP servers and skills, node manager, hosting and tasks, with the c0mpute CLI bundled.",
Expand Down
2 changes: 1 addition & 1 deletion apps/tui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0mpute/tui",
"version": "0.3.67",
"version": "0.3.68",
"private": true,
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c0mpute",
"version": "0.3.67",
"version": "0.3.68",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/app/releases/latest.json/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const dynamic = "force-dynamic";
* this in sync with the workspace version in `Cargo.toml` on each release so a
* freshly built CLI reports "already latest" rather than a phantom upgrade.
*/
const FALLBACK_VERSION = "0.3.67";
const FALLBACK_VERSION = "0.3.68";
const FALLBACK_MIN_REQUIRED = "0.0.1";

type Channel = "stable" | "beta" | "nightly";
Expand Down
95 changes: 94 additions & 1 deletion node/crates/c0mpute-core/src/buyer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ pub async fn run_auction(net: Arc<Libp2pNetwork>, auction: JobAuction) -> Result
// identity) is not a result: the job goes to the next bidder at once, and
// a valid receipt from any awarded worker ends the auction.
let mut recv_deadline = Instant::now() + receipt_wait(auction.receipt_timeout, &winner);
// A worker that fails the job (Failed/Timeout receipt) or never answers
// hands it to the next bidder from this same auction, up to MAX_REAWARDS
// times, instead of failing the whole job (2026-11-14: an outside node
// fresh on a new model won every chat and failed each after ~60 s).
let awarded_at = Instant::now();
let mut reawards = 0usize;
'receipts: loop {
while Instant::now() < recv_deadline {
let remaining = recv_deadline.saturating_duration_since(Instant::now());
match tokio::time::timeout(remaining, rx.recv()).await {
Expand Down Expand Up @@ -521,11 +528,48 @@ pub async fn run_auction(net: Arc<Libp2pNetwork>, auction: JobAuction) -> Result
}
continue;
}
if receipt.status != JobStatus::Completed
&& should_reaward(reawards, !bids.is_empty(), awarded_at.elapsed(), auction.deadline)
{
let failed = awards.swap_remove(i);
let next = bids.remove(0);
bids.retain(|b| b.bidder_peer_id != next.bidder_peer_id);
warn!(
%job_id,
worker = %failed.bid.bidder_peer_id,
status = ?receipt.status,
next = %next.bidder_peer_id,
"buyer: worker failed the job; re-awarding to the next bidder"
);
match award(&net, &auction, &offer, &session, &topic, &job_id, &next).await {
Ok(a) => {
reawards += 1;
recv_deadline = Instant::now() + receipt_wait(auction.receipt_timeout, &next);
winner = next;
awards.push(a);
continue;
}
Err(e) => {
warn!(%job_id, err = %e, "buyer: re-award failed; returning the failed receipt");
awards.push(failed);
let i = awards.len() - 1;
let a = awards.swap_remove(i);
return Ok(AuctionOutcome {
job_id,
accepted_bid: a.bid,
receipt,
external_ref: auction.external_ref.clone(),
result_key: a.result_key,
});
}
}
}
let a = awards.swap_remove(i);
info!(
%job_id,
status = ?receipt.status,
output_hash = ?receipt.output_hash,
reawards,
"buyer: receipt received"
);
return Ok(AuctionOutcome {
Expand All @@ -540,10 +584,33 @@ pub async fn run_auction(net: Arc<Libp2pNetwork>, auction: JobAuction) -> Result
Ok(Err(broadcast::error::RecvError::Lagged(n))) => {
warn!(skipped = n, "buyer: receipt stream lagged");
}
Ok(Err(_)) => break,
Ok(Err(_)) => break 'receipts,
Err(_) => break,
}
}
// No receipt in time from the current winner: the next bidder, if any.
if should_reaward(reawards, !bids.is_empty(), awarded_at.elapsed(), auction.deadline) {
let next = bids.remove(0);
bids.retain(|b| b.bidder_peer_id != next.bidder_peer_id);
warn!(
%job_id,
worker = %winner.bidder_peer_id,
next = %next.bidder_peer_id,
"buyer: no receipt in time; re-awarding to the next bidder"
);
match award(&net, &auction, &offer, &session, &topic, &job_id, &next).await {
Ok(a) => {
reawards += 1;
recv_deadline = Instant::now() + receipt_wait(auction.receipt_timeout, &next);
winner = next;
awards.push(a);
continue 'receipts;
}
Err(e) => warn!(%job_id, err = %e, "buyer: re-award failed"),
}
}
break 'receipts;
}

Err(AuctionFailure::NoReceipt(format!(
"no receipt from winner {} within {:?}",
Expand Down Expand Up @@ -981,6 +1048,17 @@ pub const REFERENCE_BENCH_SCORE: u32 = 5_000;

/// How long to wait for `winner`'s receipt: the auction's timeout, longer
/// for a winner that says it needs longer (2.5x its quoted ETA) or that
/// How many times one job moves to the next bidder after its worker failed it
/// (a Failed/Timeout receipt, or no receipt in time), on top of the first award.
pub const MAX_REAWARDS: usize = 2;

/// Should a job its worker could not finish go to the next bidder? Only while
/// there is one, re-awards are left, and the job is still inside its deadline:
/// a buyer waiting on the answer (Infernet chat) falls back on its own after.
pub(crate) fn should_reaward(reawards: usize, has_next: bool, elapsed: Duration, deadline: Duration) -> bool {
has_next && reawards < MAX_REAWARDS && elapsed < deadline
}

/// benchmarks slower than [`REFERENCE_BENCH_SCORE`] (scaled by how much
/// slower), never more than 4x the timeout. A slow CPU node (bench 1,606)
/// needed ~7 min per image against a 6 min timeout: it was benched for
Expand Down Expand Up @@ -1105,3 +1183,18 @@ mod tests {
}

}

#[cfg(test)]
mod reaward_tests {
use super::*;

#[test]
fn reawards_only_with_a_next_bidder_budget_and_time() {
let d = Duration::from_secs(300);
assert!(should_reaward(0, true, Duration::from_secs(60), d));
assert!(should_reaward(MAX_REAWARDS - 1, true, Duration::from_secs(60), d));
assert!(!should_reaward(MAX_REAWARDS, true, Duration::from_secs(60), d), "budget spent");
assert!(!should_reaward(0, false, Duration::from_secs(60), d), "nobody else bid");
assert!(!should_reaward(0, true, Duration::from_secs(301), d), "past the job deadline");
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "c0mpute-monorepo",
"version": "0.3.67",
"version": "0.3.68",
"private": true,
"workspaces": [
"apps/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/captcha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@profullstack/c0mpute-captcha",
"version": "0.3.67",
"version": "0.3.68",
"description": "Solve image, slider, gap, click-text, audio and math captchas on the c0mpute network: library (fetch().then(solveCaptcha)), CLI and stdio MCP server.",
"type": "module",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@c0mpute/shared",
"version": "0.3.67",
"version": "0.3.68",
"private": true,
"type": "module",
"main": "./dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion plugins/ad-generator-agent/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[module]
id = "ad-generator-agent"
name = "Ad Generator Agent — every ad type from one URL"
version = "0.3.67"
version = "0.3.68"
kind = "service"
category = "applications"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/ads-manager/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
[module]
id = "ads-manager"
name = "Ads Manager — shared ad operations layer"
version = "0.3.67"
version = "0.3.68"
kind = "service"
category = "applications"
status = "partial"
Expand Down
2 changes: 1 addition & 1 deletion plugins/apps/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
[module]
id = "apps"
name = "Apps — backends with 3x redundancy"
version = "0.3.67"
version = "0.3.68"
kind = "workload"
category = "infrastructure"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/captcha/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
[module]
id = "captcha"
name = "Captcha — image, slider, audio and math solving"
version = "0.3.67"
version = "0.3.68"
kind = "workload"
category = "ai"
status = "available"
Expand Down
2 changes: 1 addition & 1 deletion plugins/coinpay/module.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[module]
id = "coinpay"
name = "CoinPay — DID, payments, escrow, reputation"
version = "0.3.67"
version = "0.3.68"
kind = "service"
category = "applications"
status = "available"
Expand Down
Loading
Loading