Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(agora): make the reputation ladder actually gate, since AgenC starts every agent at 5000
nirholasebff5210c7f7
diff --git a/docs/agora.md b/docs/agora.mdindex a9b13b4fc..64f358306 100644--- a/docs/agora.md+++ b/docs/agora.md@@ -144,7 +144,11 @@ side), claim one themselves (WORK), or verify/vouch (PROVE/SPEND).to the worker on accepted proof. No trust required between strangers.- **Reputation.** Earned by completing real work; gated by `minReputation` onhigh-value tasks; backed by a **slashable stake**. New citizens grind low-value- jobs to climb — a real career ladder, not a vanity number.+ jobs to climb: a real career ladder, not a vanity number. AgenC registers every+ agent at reputation **5000** and adds **100** per accepted proof, so the ladder's+ tiers are deltas above that baseline (apprentice +0, journeyman +200, master+ +500). See the tier table in the+ [worker README](../workers/agora-citizens/README.md#reputation-ladder-the-career-ladder).- **Micro-payments.** Inside a job, a citizen can pay an x402 service per call(USDC), so value flows multi-hop: human → agent → sub-agent → service.- **Task types** map to social structures: `Exclusive` (one worker), `Competitive`diff --git a/scripts/agora-devnet-fund.mjs b/scripts/agora-devnet-fund.mjsindex b16e5634e..8815d6c59 100644--- a/scripts/agora-devnet-fund.mjs+++ b/scripts/agora-devnet-fund.mjs@@ -80,6 +80,22 @@ function loadKeypair(name) {const args = parseArgs(process.argv.slice(2));const conn = new Connection(DEVNET_RPC, 'confirmed');+// The public devnet RPC drops requests and slows to double-digit seconds once an+// IP has been hammered, and a single transient `fetch failed` should never abort+// a listing or strand a half-funded fleet.+async function balanceOf(pubkey, attempts = 6) {+ let lastErr;+ for (let i = 0; i < attempts; i++) {+ try {+ return await conn.getBalance(pubkey);+ } catch (err) {+ lastErr = err;+ await new Promise((r) => setTimeout(r, 1_000 * (i + 1)));+ }+ }+ throw new Error(`balance read failed for ${pubkey.toBase58()} after ${attempts} tries: ${lastErr?.message || lastErr}`);+}+if (args.list || args.targets.length === 0) {const keys = cacheKeys();if (!keys.length) {@@ -89,7 +105,7 @@ if (args.list || args.targets.length === 0) {console.log(`[agora-fund] cached devnet signers (${DEVNET_RPC}):`);for (const k of keys) {const kp = loadKeypair(k);- const bal = await conn.getBalance(kp.publicKey);+ const bal = await balanceOf(kp.publicKey);console.log(` ${k.padEnd(28)} ${kp.publicKey.toBase58()} ${(bal / LAMPORTS_PER_SOL).toFixed(4)} SOL`);}if (!args.list) console.log('\nPass one or more signer names to fund them from the bank wallet.');@@ -101,7 +117,7 @@ const perTarget = Math.floor(args.sol * LAMPORTS_PER_SOL);// Leave the bank enough to pay its own transfer fees and stay a working signer.const BANK_RESERVE_LAMPORTS = 10_000_000; // 0.01 SOL-const bankStart = await conn.getBalance(bank.publicKey);+const bankStart = await balanceOf(bank.publicKey);console.log(`[agora-fund] bank ${args.bank} ${bank.publicKey.toBase58()}: ${(bankStart / LAMPORTS_PER_SOL).toFixed(4)} SOL`);let spent = 0;@@ -112,7 +128,7 @@ for (const name of args.targets) {continue;}const kp = loadKeypair(name);- const have = await conn.getBalance(kp.publicKey);+ const have = await balanceOf(kp.publicKey);if (have >= perTarget) {console.log(` skip ${name}: already holds ${(have / LAMPORTS_PER_SOL).toFixed(4)} SOL`);continue;@@ -133,5 +149,5 @@ for (const name of args.targets) {console.log(` funded ${name.padEnd(24)} ${kp.publicKey.toBase58()} +${(need / LAMPORTS_PER_SOL).toFixed(4)} SOL ${sig}`);}-const bankEnd = await conn.getBalance(bank.publicKey);+const bankEnd = await balanceOf(bank.publicKey);console.log(`[agora-fund] funded ${funded}/${args.targets.length}; bank now ${(bankEnd / LAMPORTS_PER_SOL).toFixed(4)} SOL`);diff --git a/tests/agora-arena-guild.test.js b/tests/agora-arena-guild.test.jsindex bb7d236cf..682cfc77a 100644--- a/tests/agora-arena-guild.test.js+++ b/tests/agora-arena-guild.test.js@@ -21,6 +21,7 @@ import {decidePatronPost,EXCLUSIVE_TERMINAL_KINDS,MULTI_TERMINAL_KINDS,+ REPUTATION_BASELINE,} from '../workers/agora-citizens/policy.js';import { defaultPatronTiers } from '../workers/agora-citizens/demand.js';import {@@ -105,7 +106,10 @@ describe('patron demand schedule (Task 09)', () => {expect(arena).toBeTruthy();expect(arena.maxWorkers).toBe(3);expect(arena.rewardAtomic).toBe(6_000_000n);- expect(arena.minReputation).toBe(3);+ // The Arena gate is a delta above AgenC's registration baseline, so a purse+ // gated at "3" really means "3 above a fresh agent", not the absolute 3 that+ // every registered agent already clears.+ expect(arena.minReputation).toBe(REPUTATION_BASELINE + 3);expect(guild).toBeTruthy();expect(guild.maxWorkers).toBe(4);expect(guild.rewardAtomic).toBe(5_000_000n);diff --git a/tests/agora-task-supply.test.js b/tests/agora-task-supply.test.jsindex 16f95fa30..e276096c6 100644--- a/tests/agora-task-supply.test.js+++ b/tests/agora-task-supply.test.js@@ -19,6 +19,8 @@ import {citizenCanClaim,ineligibilityReason,minReputationForTier,+ REPUTATION_BASELINE,+ REPUTATION_PER_COMPLETION,pickTier,decidePatronPost,decideHire,@@ -70,11 +72,27 @@ describe('career-ladder claim gate', () => {});it('ladder tiers are documented and gate as published', () => {- expect(minReputationForTier('apprentice')).toBe(0);- expect(minReputationForTier('journeyman')).toBe(5);- expect(minReputationForTier('master')).toBe(20);+ expect(minReputationForTier('apprentice')).toBe(REPUTATION_BASELINE);+ expect(minReputationForTier('journeyman')).toBe(REPUTATION_BASELINE + 200);+ expect(minReputationForTier('master')).toBe(REPUTATION_BASELINE + 500);expect(REPUTATION_LADDER.map((t) => t.tier)).toEqual(['apprentice', 'journeyman', 'master']);});++ // The bug this pins: AgenC registers every agent at REPUTATION_BASELINE, so a+ // ladder written in absolute numbers (0/5/20) gated nothing at all. A citizen+ // that has never completed a task must be shut out of the upper tiers.+ it('gates a freshly registered citizen out of the upper tiers', () => {+ const fresh = fetcher(REPUTATION_BASELINE);+ const proven = fetcher(REPUTATION_BASELINE + 5 * REPUTATION_PER_COMPLETION);++ const apprentice = { requiredCapabilities: 1n, minReputation: minReputationForTier('apprentice') };+ const master = { requiredCapabilities: 1n, minReputation: minReputationForTier('master') };++ expect(citizenCanClaim(fresh, apprentice)).toBe(true);+ expect(citizenCanClaim(fresh, master)).toBe(false);+ expect(ineligibilityReason(fresh, master)).toBe('below_min_reputation');+ expect(citizenCanClaim(proven, master)).toBe(true);+ });});describe('patron demand policy', () => {diff --git a/workers/agora-citizens/README.md b/workers/agora-citizens/README.mdindex 43545b6bc..448047148 100644--- a/workers/agora-citizens/README.md+++ b/workers/agora-citizens/README.md@@ -209,13 +209,24 @@ climb. Patron tiers rotate across:| Tier | `minReputation` | Reward (devnet) | Who can take it ||---|---|---|---|-| **apprentice** | 0 | `AGORA_TASK_REWARD_LAMPORTS` | anyone, incl. brand-new citizens |-| **journeyman** | 5 | 2× base | a short track record |-| **master** | 20 | 4× base | proven citizens only |--A rep-2 citizen *skips* a master bounty (logged `skipping bounty — not qualified`);-a rep-≥20 citizen takes it. Climb by completing dispatcher/apprentice work (+1 rep-each).+| **apprentice** | baseline + 0 | `AGORA_TASK_REWARD_LAMPORTS` | anyone, incl. brand-new citizens |+| **journeyman** | baseline + 200 | 2x base | 2 completions |+| **master** | baseline + 500 | 4x base | 5 completions |++**The gates are deltas above AgenC's registration baseline, not absolute+numbers.** AgenC starts every registered agent at reputation **5000**+(`REPUTATION_BASELINE` in [policy.js](policy.js)) and adds **100** per accepted+proof, both measured against devnet. Written as absolutes, a ladder of 0/5/20+gates nothing: a citizen that has never worked a day already clears the top rung+by two orders of magnitude. Override the baseline with+`AGORA_REPUTATION_BASELINE` if the protocol's starting value ever changes.++So a freshly registered citizen (rep 5000) *skips* a master bounty, logged as+`skipping bounty: not qualified` with `reason: "below_min_reputation"`; after 5+completed tasks (rep 5500) it takes the same bounty. The skip log always names+which gate rejected it, because `missing_capability` (the common case, a citizen+without the required profession bit) and `below_min_reputation` are completely+different diagnoses.## Task 09 — Arena (Competitive) + Guilds (Collaborative)diff --git a/workers/agora-citizens/config.js b/workers/agora-citizens/config.jsindex 66f55262b..43f48aa16 100644--- a/workers/agora-citizens/config.js+++ b/workers/agora-citizens/config.js@@ -129,8 +129,12 @@ export function loadConfig() {arenaRewardMultiplier: Math.max(1, num('AGORA_ARENA_REWARD_MULT', 6)),guildRewardMultiplier: Math.max(1, num('AGORA_GUILD_REWARD_MULT', 6)),// Arena carries a reputation gate (a juicy purse belongs to proven racers);- // a Guild is open entry work so newcomers can contribute and climb.- arenaMinReputation: Math.max(0, num('AGORA_ARENA_MIN_REP', 3)),+ // a Guild is open entry work so newcomers can contribute and climb. This is a+ // DELTA above AgenC's registration baseline (policy.js REPUTATION_BASELINE),+ // not an absolute: every registered agent already starts at the baseline, so+ // an absolute gate of 3 would let a citizen with zero completions straight in.+ // 100 is one completed task.+ arenaMinReputation: Math.max(0, num('AGORA_ARENA_MIN_REP', 100)),// Minimum on-chain stake per agent (AgenC protocol minAgentStake on devnet).stakeLamports: Math.max(1_000_000, num('AGORA_STAKE_LAMPORTS', 1_000_000)),diff --git a/workers/agora-citizens/demand.js b/workers/agora-citizens/demand.jsindex 8f6ba0985..1f398962d 100644--- a/workers/agora-citizens/demand.js+++ b/workers/agora-citizens/demand.js@@ -11,7 +11,7 @@// faucet refills it), the allowance bounds devnet posting so it's visibly finite.import { PublicKey } from '@solana/web3.js';-import { decidePatronPost, decideHire } from './policy.js';+import { decidePatronPost, decideHire, REPUTATION_BASELINE } from './policy.js';import { postBounty } from './post.js';import { log } from './log.js';@@ -64,10 +64,14 @@ export function subtaskReward(cfg) {*/export function defaultPatronTiers(cfg) {const base = BigInt(cfg.taskRewardLamports); // devnet: 0.001 SOL default+ // minReputation is omitted on purpose: decidePatronPost fills it from+ // REPUTATION_LADDER, so the ladder in policy.js stays the single source of+ // truth for what each tier gates on. Restating the numbers here is how they+ // drifted into being absolutes that gate nothing.const tiers = [- { tier: 'apprentice', profession: 'fetcher', rewardAtomic: base, minReputation: 0 },- { tier: 'apprentice', profession: 'fetcher', rewardAtomic: base, minReputation: 0 },- { tier: 'journeyman', profession: 'fetcher', rewardAtomic: base * 2n, minReputation: 5 },+ { tier: 'apprentice', profession: 'fetcher', rewardAtomic: base },+ { tier: 'apprentice', profession: 'fetcher', rewardAtomic: base },+ { tier: 'journeyman', profession: 'fetcher', rewardAtomic: base * 2n },];// Arena — a Competitive purse several citizens race for; the first valid proof// takes the WHOLE escrow. Gated on reputation so a juicy purse belongs to@@ -78,12 +82,13 @@ export function defaultPatronTiers(cfg) {tier: 'arena',profession: 'fetcher',rewardAtomic: base * BigInt(cfg.arenaRewardMultiplier ?? 6),- minReputation: cfg.arenaMinReputation ?? 0,+ // A delta above the registration baseline, like every ladder gate.+ minReputation: REPUTATION_BASELINE + (cfg.arenaMinReputation ?? 0),taskType: 'Competitive',maxWorkers: cfg.arenaMaxWorkers ?? 3,});}- tiers.push({ tier: 'master', profession: 'fetcher', rewardAtomic: base * 4n, minReputation: 20 });+ tiers.push({ tier: 'master', profession: 'fetcher', rewardAtomic: base * 4n });// Guild — a Collaborative pool that SPLITS across contributors. Open entry work// (minReputation 0) so newcomers can contribute a real part and climb.if (cfg.enableGuild) {diff --git a/workers/agora-citizens/engine.js b/workers/agora-citizens/engine.jsindex 1cb439acb..2b40386e5 100644--- a/workers/agora-citizens/engine.js+++ b/workers/agora-citizens/engine.js@@ -18,7 +18,7 @@import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js';import { log } from './log.js';import { buildRoster, professionBits, capabilitiesSatisfy, PROFESSIONS } from './roster.js';-import { citizenCanClaim, normalizeTaskType, isMultiWorkerType, isArenaType, TASK_TYPES } from './policy.js';+import { citizenCanClaim, ineligibilityReason, normalizeTaskType, isMultiWorkerType, isArenaType, TASK_TYPES } from './policy.js';import { markPatrons, maybePatronPost, maybePatronVerify, maybeHire, hiringEnabled, subtaskReward } from './demand.js';import { arenaWonNarrative, arenaLostNarrative, guildContributedNarrative } from './narrative.js';import { loadOrCreateKeypair, ensureBalance } from './keypair.js';@@ -428,16 +428,22 @@ async function pickBoardBounty(ctx, citizen) {if (isSelfDealing(t, citizen.id)) continue;// Career-ladder gate from the projection (surfaced by /api/agora/board).- const eligible = citizenCanClaim(citizen, {+ const gate = {requiredCapabilities: t.requiredCapabilities ?? 0,minReputation: t.minReputation ?? 0,- });- if (!eligible) {- log.loop('skipping bounty — not qualified', {+ };+ if (!citizenCanClaim(citizen, gate)) {+ // Report WHICH gate rejected it. Logging the reputation pair alone read as+ // a rep failure even when the citizen simply lacked the capability bit,+ // which is the common case and a completely different diagnosis.+ const reason = ineligibilityReason(citizen, gate);+ log.loop('skipping bounty: not qualified', {name: citizen.spec.displayName,taskPda: t.taskPda,- needRep: t.minReputation ?? 0,- haveRep: citizen.reputation,+ reason,+ ...(reason === 'below_min_reputation'+ ? { needRep: gate.minReputation, haveRep: citizen.reputation }+ : { needCaps: String(gate.requiredCapabilities), haveCaps: String(citizen.capabilityBits) }),tier: t.tier || null,});continue;diff --git a/workers/agora-citizens/policy.js b/workers/agora-citizens/policy.jsindex 367123946..06ecb275c 100644--- a/workers/agora-citizens/policy.js+++ b/workers/agora-citizens/policy.js@@ -54,14 +54,26 @@ export function isGuildType(t) { return normalizeTaskType(t) === TASK_TYPES.COLL// documented here and surfaced in the worker README. minReputation is the// on-chain gate written into each posted task.//-// apprentice rep ≥ 0 — entry work, anyone (incl. brand-new citizens)-// journeyman rep ≥ 5 — needs a short track record-// master rep ≥ 20 — reserved for proven citizens; the top of the board+// The gates are a DELTA above AgenC's registration baseline, not absolute+// numbers. AgenC starts every registered agent at REPUTATION_BASELINE and adds+// REPUTATION_PER_COMPLETION per accepted proof, so an absolute ladder of 0/5/20+// gates nothing at all: a citizen that has never worked a day already clears it+// by two orders of magnitude. Deltas make the ladder real, because a fresh+// citizen sits exactly at the baseline and has to complete real work to climb.+// Measured on devnet 2026-08-06: a freshly registered agent reads reputation+// 5000, and each completed task adds 100.+//+// apprentice baseline + 0 entry work, anyone (incl. brand-new citizens)+// journeyman baseline + 200 needs a short track record (2 completions)+// master baseline + 500 proven citizens only (5 completions)+export const REPUTATION_BASELINE = Number(process.env.AGORA_REPUTATION_BASELINE) || 5000;+export const REPUTATION_PER_COMPLETION = 100;+export const REPUTATION_LADDER = [- { tier: 'apprentice', minReputation: 0 },- { tier: 'journeyman', minReputation: 5 },- { tier: 'master', minReputation: 20 },-];+ { tier: 'apprentice', minReputationDelta: 0 },+ { tier: 'journeyman', minReputationDelta: 200 },+ { tier: 'master', minReputationDelta: 500 },+].map((t) => ({ ...t, minReputation: REPUTATION_BASELINE + t.minReputationDelta }));const LADDER_BY_TIER = new Map(REPUTATION_LADDER.map((t) => [t.tier, t]));