ShijimaDocs
Open app
Architecture

The wake loop

Two clocks, one look per five-minute slot, and every step from reading the chain to a Telegram message.

Reviewed 2026-09-26

Two clocks

ClockWhenTrigger name
OpenServThe workflow's cron, at the top of every hourcron
The worker's timerA pass every 15 seconds; each agent is looked at once per five-minute slotwatch, or tick for the hour's slot and quiet days

A look is stored with its slot time, and the database allows one look per agent per slot. Whichever clock arrives first does the work; the other finds it already done. At the top of the hour the timer waits four minutes, so OpenServ gets the first go and its trigger is really used.

Other triggers: manual for “check now”, and copy when a leader you follow moved.

One pass of the worker

Each pass, in order:

  1. Pending “check now” requests.
  2. For each running agent: its look, then grading at the reopen, then the daily seal if one is due.
  3. Copying leaders' moves to followers.
  4. Price logging and price alerts.
  5. Market facts: multiplier events such as splits every hour, earnings dates every 12 hours.
  6. A check that the operator has enough ETH for gas.

One look

Sequence

One wake, start to finish

What happens each time your agent looks. Most looks stop at step 5 with nothing to do.

Shijima
ONLY WHEN A NEED PASSESClockOpenServ or timerWorkerthe engineChainyour Desk · poolsSERVReasoningPostgresthe recordTelegramyou1 wake: hourly task or 5-minute watch2 settle any earlier send first3 reconcile: balances, limits, seq4 value on each pool’s 30-min average5 needs: drift past tolerance?6 pre-gate: halted, feed, band, list7 one question: when?8 now · in part · wait · decline9 gate: your limits, the contract’s sums10 record hashed, send planned11 trade carrying the decision hash12 receipt and event13 result appended14 status edited · “I did this”
Steps 1 to 5 and 9 are arithmetic or fixed rules. Step 7 is the only AI call, and it only chooses the timing. The record is saved and hashed before the transaction is signed, so a crash can never lose a trade.
Read it as text
  1. Clock Worker: wake: hourly task or 5-minute watch
  2. Worker: settle any earlier send first
  3. Worker Chain: reconcile: balances, limits, seq
  4. Worker Chain: value on each pool’s 30-min average
  5. Worker: needs: drift past tolerance?
  6. Worker: pre-gate: halted, feed, band, list
  7. Worker SERV: one question: when?
  8. SERV Worker: now · in part · wait · decline
  9. Worker: gate: your limits, the contract’s sums
  10. Worker Postgres: record hashed, send planned
  11. Worker Chain: trade carrying the decision hash
  12. Chain Worker: receipt and event
  13. Worker Postgres: result appended
  14. Worker Telegram: status edited · “I did this”

One wake, start to finish

Shijima
ONLY WHEN A NEED PASSESClockOpenServ or timerWorkerthe engineChainyour Desk · poolsSERVReasoningPostgresthe recordTelegramyou1 wake: hourly task or 5-minute watch2 settle any earlier send first3 reconcile: balances, limits, seq4 value on each pool’s 30-min average5 needs: drift past tolerance?6 pre-gate: halted, feed, band, list7 one question: when?8 now · in part · wait · decline9 gate: your limits, the contract’s sums10 record hashed, send planned11 trade carrying the decision hash12 receipt and event13 result appended14 status edited · “I did this”

Steps 1 to 5 and 9 are arithmetic or fixed rules. Step 7 is the only AI call, and it only chooses the timing. The record is saved and hashed before the transaction is signed, so a crash can never lose a trade.

In the code (packages/core/src/wake/):

StepFileWhat it does
Startwake.tsSkips an agent with no mandate, not running, or whose assistant was removed. Claims the slot.
Reconcilereconcile.tsReads the contract. Checks it is a clone of our implementation, with our operator and the right owner. Owner calls since the last look are accepted; anything else flags needs attention.
Valuevaluation.tsEvery holding at its pool's 30-minute average. Money in or out moves the loss baseline.
Loss stoploss-stop.tsFirst breach stops trading; a second in a row pauses the contract on chain.
Approvedapproved.tsRuns requests you approved, with a fresh price and no AI call.
Vaultvault.tsTakes cash out of savings if buys need it.
Needsneeds.tsArithmetic. Up to three candidates. None: a watching look writes nothing.
Considerconsider.tsPer candidate: market read, gate, pre-gate, an owner's earlier answer, a standing wait, then SERV, then the gate again on the sized move.
Planplan.tsApplies your mode: would have, ask, or act. Large actions ask.
Commitcommit.tsOne database transaction: the record, plus any wait, request or message. The send happens after it commits.
Sweepvault.tsIdle cash into savings, when worth it.
Finishwake.tsQueues the status message and closes the look.

Messages go out through an outbox: the look writes them to Postgres, and the Telegram bot sends them after the pass. A message is never lost to a Telegram hiccup, and never sent for a trade that did not confirm.

Savings sweeps

Only an agent that acts on its own sweeps. It moves the idle part of your cash target into the Morpho vault when there is at least $10 to move and a month of interest is at least three times the network fee of going in and out. Before buys, it takes out enough to cover them, keeping three times your per-trade limit loose.

Next: what the contract enforces.

Source notes

This page was checked against the code on 2026-09-26. These are the files it follows.

On this page