惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
爱范儿
爱范儿
Y
Y Combinator Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
Know Your Adversary
Know Your Adversary
P
Proofpoint News Feed
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
G
GRAHAM CLULEY
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
C
Cyber Attacks, Cyber Crime and Cyber Security
T
The Blog of Author Tim Ferriss
T
The Exploit Database - CXSecurity.com
博客园 - 叶小钗
Latest news
Latest news
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
量子位
S
Security @ Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
美团技术团队
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
IT之家
IT之家
U
Unit 42
Project Zero
Project Zero
B
Blog
博客园 - 【当耐特】
D
DataBreaches.Net
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
F
Full Disclosure
Vercel News
Vercel News
NISL@THU
NISL@THU
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
T
Threatpost
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
T
Tor Project blog
M
MIT News - Artificial intelligence
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Architecting a Self Governing De-Fi Agent - Here's How It Ranked
Ola Adesoye · 2026-05-21 · via DEV Community

What if your AI trading agent couldn't execute a single trade unless you had explicitly told it that it was allowed to?

Not "the AI will try its best to follow your preferences." Not "there's a risk limit slider somewhere in the settings." I mean a hard, synchronous block. As long as the rule doesn't exist in the constitution? No execution. That's it.

I pondered on the initial question for a while. Every DeFi agent content I'd seen seemed to majorly focus on capability — what the agent can do. Almost none of them addressed constraint — what it categorically cannot do, and more importantly, how you prove it held the line.

I recently built Nostra: a constitutional DeFi agent running on ElizaOS v2 and deployed on Nosana's decentralized GPU network. It just ranked #6 out of 105 submissions across 32 countries in Nosana's Fourth Builders' Challenge. The judges called it "a thoughtful approach to trust, compliance, and agent responsibility" — which, honestly, felt great to read after two weeks of late-night debugging.

Let's walk through how it works. Including the parts that didn't.


The Core Idea: Your Agent Has a Constitution

Most AI agents have a skillset that directs them regarding what they do. Nostra has rules.

A Nostra constitution is a structured document you write once during onboarding. It gets parsed into typed ConstitutionRule objects and stored in SQLite:

// src/types/constitution.ts
export interface ConstitutionRule {
  id: number;          // Rule #N — matches on-chain memo references
  type: 'allocation_limit' | 'yield_threshold' | 'action_gate' | 'compute_budget' | 'custom';
  description: "string; // Plain-English — used verbatim in Lamport memos"
  condition: {
    metric: string;    // e.g. "sol_concentration", "yield_delta"
    operator: '<' | '>' | '<=' | '>=' | '==' | '!=';
    value: number;
    unit: string;      // e.g. "percent", "apy_points"
  };
  action: 'block' | 'alert' | 'require_approval' | 'reduce_frequency';
}

Enter fullscreen mode Exit fullscreen mode

The key insight here: the rule's description field is the exact string that gets written to the Solana blockchain when the rule fires. It is retained in its exact form without translation or paraphrasing. What you wrote is what gets logged. We'll come back to why that matters.


The Architecture: Three Gates Before Any Trade

Here's the flow every action has to survive before Nostra will touch your money:

All three gates live in a single higher-order function called withComplianceGate. It wraps any ElizaOS Action like this:

// src/index.ts — action registration
actions: [
  HandleStartCommand,
  ParseConstitutionAction,
  LogDecisionOnChain,
  withComplianceGate(ExecuteRotation),  // ← only execution actions get gated
  TriggerCrisisProtocol,
  AmendConstitution,
  // ...18+ total actions
],

Enter fullscreen mode Exit fullscreen mode

Notice ExecuteRotation is the only action wrapped. Informational commands, constitution management, and crisis handling are all deliberately outside the gate — you always need to be able to talk to your agent, even when it's frozen.

Here's the gate itself (abridged):

// src/gates/with-compliance-gate.ts
function withComplianceGateHandler(handler: ActionHandler): ActionHandler {
  return async (runtime, message, state, options, callback) => {
    const agentState = AgentStateService.getState();

    // Gate 1: Crisis Protocol — block if frozen or resolving
    if (agentState.crisisStatus !== 'active') {
      await sendCallback(callback,
        `All actions are frozen. Crisis Protocol status: ${agentState.crisisStatus}.`
      );
      return;
    }

    // Gate 2: Constitutional compliance — live DB read every time
    const constitution = ConstitutionService.getActive(db);
    if (constitution && constitution.rules.length > 0) {
      const proposed = extractProposedAction(message);
      if (proposed) {
        const result = checkConstitutionalCompliance(constitution.rules, proposed);
        if (!result.passed) {
          // Write a NON_ACTION memo to Solana — even the block is recorded
          const memoText = buildMemoText({
            actionDescription: `NON_ACTION: ${result.violation}`,
            ruleReference: `Rule #${result.ruleRef}`,
            complianceStatus: 'Constitutional compliance: BLOCKED.',
          });
          await WalletService.writeMemo(memoText);
          await sendCallback(callback, `Action blocked: ${result.violation}`);
          return;
        }
      }
    }

    // Gate 3: Trust Ladder — block if still in Advisor Mode
    if (agentState.trustLadder === 'advisor') {
      await sendCallback(callback,
        `Advisory Mode. Current accuracy: ${agentState.accuracyScore.toFixed(1)}%`
      );
      return;
    }

    return handler(runtime, message, state, options, callback);
  };
}

Enter fullscreen mode Exit fullscreen mode

There's one detail in Gate 2 I want to highlight: ConstitutionService.getActive(db) is a fresh database read on every action. No caching. This was intentional — if you amend your constitution mid-session, the very next proposed action sees the updated rules. Eventual consistency in governance is not a vibe I wanted to ship.


The Trust Ladder: Earning the Right to Execute

So here's the thing. Even if your constitution is perfectly configured, Nostra doesn't just start executing trades on day one. It starts in Advisor Mode.

In Advisor Mode, the agent observes, analyzes, and suggests what it would do, but every suggestion goes to you for grading. Thumbs up, thumbs down. The TrustLadderEvaluator tracks your scores:

// src/evaluators/trust-ladder-evaluator.ts
const MIN_SAMPLE_FOR_PROMOTION = 5;

// Threshold: >= 80% accuracy with at least 5 graded entries
if (accuracyScore >= 80 && total >= MIN_SAMPLE_FOR_PROMOTION) {
  const state = AgentStateService.getState();
  if (!state.promotionPending) {
    update['promotionPending'] = true;  // triggers promotion flow
  }
}

Enter fullscreen mode Exit fullscreen mode

Once the agent hits 80% accuracy across at least 5 graded suggestions, it flags for promotion. You review and explicitly approve the upgrade to Executor Mode. Only then can it touch your actual funds.

This felt like a small detail at design time. In practice, it's the whole point since it forces a natural calibration period and means you've seen the agent's decision-making style before you hand it real authority.


The Lamport Conscience: On-Chain Proof of Every Decision

This is my favorite part of the project, and also the part that required the most care.

Every action — and every blocked action — gets written to the Solana Memo Program. It was an intentional move not to use a log file or a database entry. Instead, it felt just right to use an immutable, on-chain record you own forever. I called it the Lamport Conscience (because Lamports are the smallest unit of SOL, and conscience is… the smallest unit of accountability, maybe?).

// src/actions/log-decision-on-chain.ts
export function buildMemoText(params: MemoParams): string {
  const timestamp = new Date().toISOString();
  const { ruleReference, complianceStatus } = params;

  const fixedPart = `${timestamp} — `;
  const suffix = ` ${ruleReference}. ${complianceStatus}`;
  const maxDescriptionLength = MEMO_MAX_CHARS - fixedPart.length - suffix.length;

  let desc = params.actionDescription;
  if (desc.length > maxDescriptionLength) {
    desc = desc.slice(0, maxDescriptionLength - 1) + '';
  }

  return `${fixedPart}${desc}${suffix}`;
}

Enter fullscreen mode Exit fullscreen mode

A real memo looks like this:

2026-04-12T14:32:11.204Z — Rotate 15% SOL → USDC via Jupiter. Rule #2. Constitutional compliance: 100%.

Enter fullscreen mode Exit fullscreen mode

And a blocked one:

2026-04-12T14:35:02.871Z — NON_ACTION: sol_concentration 72% exceeds max 60%. Rule #3. Constitutional compliance: BLOCKED.

Enter fullscreen mode Exit fullscreen mode

Both get broadcast to the chain. The agent proves what it did and what it refused to do. That's the audit trail that makes "your rules" actually mean something.


The Crisis Protocol: When Things Go Sideways

Here's where it gets fun. What happens when the agent detects a catastrophic market condition, such as a cascade liquidation, a de-peg, or a flash crash?

It freezes itself. Completely. No new actions can pass Gate 1. Then it does three things:

  1. Writes an emergency memo to Solana documenting the crisis
  2. Generates a crisis briefing using the LLM (Qwen3.5-27B on Nosana's GPU)
  3. Sends you three resolution options on Telegram with explicit tradeoffs — A (lowest risk), B (medium), C (highest risk)

You vote. The agent executes your choice. This was genuinely tricky to implement because the LLM response has to be structured JSON, and LLMs are famously bad at being told "output ONLY valid JSON, no other text." The prompt engineering to make that reliable took more iterations than I'd like to admit.


Deploying on Nosana: The amd64 Trap

Right. Here's the honest moment.

I spent almost half a day confused about why my Docker image was failing on Nosana nodes. Everything worked locally. The image built fine. The job would post, and then... nothing. Silent failure.

Nosana runs on x86_64 nodes. My dev machine is Apple Silicon. When you run docker build on an M-series Mac without specifying the platform, you get an arm64 image. Nosana can't run it.

The fix is one flag, but you have to know to look for it:

# This is the command that actually works on Nosana
docker buildx build --platform linux/amd64 -t yourusername/nostra:latest --push .

Enter fullscreen mode Exit fullscreen mode

And secrets — never bake them into the image. Nosana has a secrets manager for this:

nosana secret create TELEGRAM_BOT_TOKEN <your-token>
nosana secret create SOLANA_PRIVATE_KEY <base58-keypair>
nosana secret create ALCHEMY_RPC_URL <your-rpc-url>

Enter fullscreen mode Exit fullscreen mode

Then your job definition references them at runtime. This is the right pattern. Don't skip it.


The Full Stack at a Glance


What I Learned (And Would Do Differently)

What worked well:

  • ElizaOS v2's Provider/Action/Evaluator pattern is genuinely well-designed for this kind of layered architecture. The separation of concerns maps cleanly to "observe → decide → act."
  • Socratic onboarding — where the agent asks you 6 probing questions about your risk tolerance and investment philosophy before generating your constitution — turned out to be the highest-value UX decision. Users who go through it understand their own rules better.
  • The Lamport Conscience felt "extra" when I was designing it. But when you go into the details, it's consistently one of the things people find most interesting.

What I'd do differently in V2:

  • SQLite is fine for a single Nosana node. The moment you want multi-node deployment (and you will), you need PostgreSQL. The Crisis Protocol freeze needs row-level locking across nodes, which SQLite can't give you.
  • In-memory keypair signing works for a challenge submission. For production, hardware wallet signing (Ledger via @solana/hw-wallet-adapter) is the only honest answer for a non-custodial agent.
  • I'd write more integration tests earlier. The action tests I have are good, but the gates-under-load path wasn't tested until it was already in the Nosana job.

Go Build Something

The full project is open-source: github.com/Zolldyk/Nostra (branch: elizaos-challenge)

If you're building anything in the AI agent x DeFi space, especially if you're thinking about governance, accountability, or trust models for autonomous agents, I'd genuinely love to compare notes. Drop a comment, open an issue, or just fork it and see where you can take it.

The question I started with — what if an agent couldn't break its own rules? — has a lot more surface area than I initially thought. There are entire research fields pointing at this problem (corrigibility, value alignment, Constitutional AI). I didn't solve any of them. But I did build something that makes them concrete and tangible in a DeFi context, and I think that's worth exploring further.