Skip to content

feat(agent): add gap-aware liquidation watcher demo#30

Merged
simonovic86 merged 1 commit intomainfrom
claude/pensive-ellis
Mar 17, 2026
Merged

feat(agent): add gap-aware liquidation watcher demo#30
simonovic86 merged 1 commit intomainfrom
claude/pensive-ellis

Conversation

@simonovic86
Copy link
Owner

Summary

  • Adds a liquidation risk watcher agent that proves continuity through missing time — the canonical "killer demo" for Igor
  • Agent monitors a simulated ETH position against a deterministic price curve (pure function of discrete time slots)
  • On resume after downtime, detects the gap, replays missed slots with [catch-up] prefix, discovers the liquidation threshold was breached during the outage, and seamlessly transitions to [live] processing
  • The six "oh" moments: same DID before/after, different node, last processed slot shown, gap detected, missed interval replayed, correct alert from downtime events

What this proves

Not just checkpoint/resume. Gap-awareness: the agent knows it was absent, the world advanced anyway, it reconstructs what happened, and reaches the correct conclusion. The [catch-up][live] transition is the emotional center.

Files

  • agents/liquidation/main.go — 227-line gap-aware watcher with authored price curve
  • agents/liquidation/Makefile, go.mod, agent.manifest.json — build scaffolding
  • scripts/demo-liquidation.sh — full 5-scene demo script (~55 seconds)
  • Makefileagent-liquidation and demo-liquidation targets
  • CLAUDE.md — updated with new agent/demo references

Test plan

  • make agent-liquidation builds successfully
  • go test -v -race ./... all tests pass
  • make check passes (fmt, vet, lint, test)
  • make demo-liquidation runs the full 55-second demo end-to-end

🤖 Generated with Claude Code

Adds a liquidation risk watcher agent that proves continuity through
missing time — not just checkpoint/resume, but gap detection, catch-up
replay of missed time slots, and retroactive event discovery.

The agent monitors a simulated ETH position against a deterministic
price curve (pure function of discrete time slots). On resume after
downtime, it detects the gap, replays missed slots with [catch-up]
prefix, discovers that the liquidation threshold was breached during
the outage, and seamlessly transitions to [live] processing.

Demo: make demo-liquidation (~55 seconds)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@simonovic86 simonovic86 merged commit 237af6b into main Mar 17, 2026
1 check passed
@simonovic86 simonovic86 deleted the claude/pensive-ellis branch March 17, 2026 23:37
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9bff58c07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
w.LastNano = now

currentSlot := uint64((now - w.BirthNano) / 1_000_000_000)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard negative elapsed time before casting to uint64

If this checkpoint is resumed on a node whose clock is behind the node that created BirthNano (or after a backward clock adjustment), (now - w.BirthNano) becomes negative here and the cast to uint64 wraps to a huge value; that makes currentSlot enormous and drives a massive fake gap replay, so resume can hang/fail and produce incorrect catch-up behavior in cross-node scenarios.

Useful? React with 👍 / 👎.

Comment on lines +124 to +125
for slot := w.LastProcessedSlot + 1; slot < currentSlot; slot++ {
w.processSlot(slot, "catch-up")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit catch-up replay work per tick

This loop replays every missed slot in a single Tick, and each iteration calls processSlot (including igor.Logf), so replay cost grows linearly with downtime; because the runtime enforces a 15s tick deadline (internal/agent/instance.go), longer outages can cause timeout during catch-up and prevent the agent from reaching live mode after resume.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant