Skip to content

Commit 0a64d58

Browse files
simonovic86claude
andauthored
docs + refactor: fix audit inconsistencies, decouple product from research packages (#26)
* feat(sdk): add effect lifecycle model and treasury sentinel demo agent The effect model makes crash-safe side effects a runtime primitive. IntentState machine: Recorded → InFlight → Confirmed, with the "resume rule" (InFlight → Unresolved on Unmarshal) for safe crash recovery. Treasury sentinel agent demonstrates the pattern end-to-end. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: fix 10 documentation inconsistencies found in audit - Fix tick timeout 100ms → 15s across 4 files (matches config.TickTimeout) - Fix igord resume CLI syntax (positional → --checkpoint/--wasm flags) - Add HTTP hostcall documentation to HOSTCALL_ABI.md - Fix IMPLEMENTATION_STATUS.md: flag attribution (igord-lab not igord), add HTTP/effects/pricewatcher/sentinel entries, fix stale claims - Update ROADMAP.md Phase 2 with completed items and current status - Fix stale phase references and lease version (v0x03 → v0x04) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor(agent): decouple product binary from research-only packages Break the transitive dependency chain that pulled authority and config packages into the product igord binary: - Extract DefaultTickTimeout (15s) into internal/agent, replacing config.TickTimeout usage in the product path - Define EpochData struct in internal/agent to replace authority.Epoch in checkpoint headers; Instance.Lease becomes `any` with LeaseInfo interface for checkpoint building - Extract duplicated loadOrGenerateIdentity into pkg/identity/loader.go with a minimal Store interface - Move research agents (example, reconciliation) under agents/research/ - Move cmd/demo-reconciliation into agents/research/reconciliation/cmd/demo/ - Update Makefile, CLAUDE.md, and all doc references for new paths Verified: `go list -deps ./cmd/igord/ | grep -E 'authority|config'` returns nothing — product binary is fully decoupled. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: set LICENSE copyright to Janko Simonovic Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(agent): address PR review — checkpoint-before-execute and unmarshal bounds check - Sentinel: return false (standard 1s tick) after recording a refill intent so the runtime persists a checkpoint before executeRefill runs. Previously returned true (10ms fast tick), risking intent loss on crash. - EffectLog.Unmarshal: add bounds check before reading state byte to prevent panic on truncated effect-log payloads during resume. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e0c04bd commit 0a64d58

46 files changed

Lines changed: 1606 additions & 204 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ Igor is the runtime for portable, immortal software agents. The checkpoint file
1515
```bash
1616
make bootstrap # Install toolchain (Go, golangci-lint, goimports, TinyGo)
1717
make build # Build igord → bin/igord
18-
make agent # Build example WASM agent → agents/example/agent.wasm
18+
make agent # Build example WASM agent → agents/research/example/agent.wasm
1919
make agent-heartbeat # Build heartbeat WASM agent → agents/heartbeat/agent.wasm
2020
make agent-pricewatcher # Build price watcher WASM agent → agents/pricewatcher/agent.wasm
21+
make agent-sentinel # Build treasury sentinel WASM agent → agents/sentinel/agent.wasm
2122
make test # Run tests: go test -v ./...
2223
make lint # golangci-lint (5m timeout)
2324
make vet # go vet
@@ -27,6 +28,7 @@ make run-agent # Build + run example agent with budget 1.0
2728
make demo # Build + run bridge reconciliation demo
2829
make demo-portable # Build + run portable agent demo (run → stop → copy → resume → verify)
2930
make demo-pricewatcher # Build + run price watcher demo (fetch prices → stop → resume → verify)
31+
make demo-sentinel # Build + run treasury sentinel demo (effect lifecycle → crash → reconcile)
3032
make clean # Remove bin/, checkpoints/, agent.wasm
3133
```
3234

@@ -35,14 +37,14 @@ Run a single test: `go test -v -run TestName ./internal/agent/...`
3537
Run manually (new subcommands):
3638
```bash
3739
./bin/igord run --budget 1.0 agents/heartbeat/agent.wasm
38-
./bin/igord resume checkpoints/heartbeat/checkpoint.ckpt agents/heartbeat/agent.wasm
40+
./bin/igord resume --checkpoint checkpoints/heartbeat/checkpoint.ckpt --wasm agents/heartbeat/agent.wasm
3941
./bin/igord verify checkpoints/heartbeat/history/
4042
./bin/igord inspect checkpoints/heartbeat/checkpoint.ckpt
4143
```
4244

4345
Legacy mode (P2P/migration):
4446
```bash
45-
./bin/igord --run-agent agents/example/agent.wasm --budget 10.0
47+
./bin/igord --run-agent agents/research/example/agent.wasm --budget 10.0
4648
./bin/igord --migrate-agent local-agent --to /ip4/127.0.0.1/tcp/4002/p2p/<peerID> --wasm agent.wasm
4749
```
4850

@@ -79,18 +81,21 @@ Atomic writes via temp file → fsync → rename. Every checkpoint is also archi
7981
- `pkg/manifest/` — Capability manifest parsing and validation
8082
- `pkg/protocol/` — Message types: `AgentPackage`, `AgentTransfer`, `AgentStarted`
8183
- `pkg/receipt/` — Payment receipt data structure, Ed25519 signing, binary serialization
82-
- `sdk/igor/` — Agent SDK: hostcall wrappers (ClockNow, RandBytes, Log, WalletBalance), lifecycle plumbing (Agent interface), Encoder/Decoder with Raw/FixedBytes/ReadInto for checkpoint serialization
84+
- `sdk/igor/` — Agent SDK: hostcall wrappers (ClockNow, RandBytes, Log, WalletBalance), lifecycle plumbing (Agent interface), Encoder/Decoder with Raw/FixedBytes/ReadInto for checkpoint serialization, EffectLog for intent tracking across checkpoint/resume
85+
- `sdk/igor/effects.go` — Effect lifecycle primitives: EffectLog, IntentState (Recorded→InFlight→Confirmed/Unresolved→Compensated), the resume rule (InFlight→Unresolved on Unmarshal)
8386
- `agents/heartbeat/` — Demo agent: logs heartbeat with tick count and age, milestones every 10 ticks
8487
- `agents/pricewatcher/` — Demo agent: fetches BTC/ETH prices from CoinGecko, tracks high/low/latest across checkpoint/resume
85-
- `agents/example/` — Original demo agent (Survivor) from research phases
88+
- `agents/sentinel/` — Treasury sentinel: monitors simulated treasury balance, triggers refills with effect-safe intent tracking, demonstrates crash recovery and reconciliation
89+
- `agents/research/example/` — Original demo agent (Survivor) from research phases
90+
- `agents/research/reconciliation/` — Bridge reconciliation demo agent (research phase)
8691
- `scripts/demo-portable.sh` — End-to-end portable agent demo
8792

8893
### Migration flow
8994
Source checkpoints → packages (WASM + checkpoint + budget) → transfers over libp2p → target instantiates + resumes → target confirms → source terminates + deletes local checkpoint. Single-instance invariant maintained throughout. Failures classified as retriable/fatal/ambiguous; ambiguous transfers enter RECOVERY_REQUIRED state (EI-6). Retry with exponential backoff; peer registry tracks health for target selection.
9095

9196
### CLI subcommands (Product Phase 1)
9297
- `igord run [flags] <agent.wasm>` — run agent with new identity (`--budget`, `--checkpoint-dir`, `--agent-id`)
93-
- `igord resume <checkpoint.ckpt> <agent.wasm>` — resume agent from checkpoint file
98+
- `igord resume --checkpoint <path> --wasm <path>` — resume agent from checkpoint file
9499
- `igord verify <history-dir>` — verify checkpoint lineage chain
95100
- `igord inspect <checkpoint.ckpt>` — display checkpoint details with DID identity
96101

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"Refer to the LICENSE file" or similar statement added to each
187187
source file to indicate the file is part of the licensed work.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2025 Janko Simonovic
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
.PHONY: help bootstrap build build-lab clean test lint vet fmt fmt-check tidy agent agent-heartbeat agent-reconciliation agent-pricewatcher run-agent demo demo-portable demo-pricewatcher gh-check gh-metadata gh-release
1+
.PHONY: help bootstrap build build-lab clean test lint vet fmt fmt-check tidy agent agent-heartbeat agent-reconciliation agent-pricewatcher agent-sentinel run-agent demo demo-portable demo-pricewatcher demo-sentinel gh-check gh-metadata gh-release
22

33
.DEFAULT_GOAL := help
44

55
# Build configuration
66
BINARY_NAME := igord
77
BINARY_DIR := bin
8-
AGENT_DIR := agents/example
8+
AGENT_DIR := agents/research/example
99
HEARTBEAT_AGENT_DIR := agents/heartbeat
10-
RECONCILIATION_AGENT_DIR := agents/reconciliation
10+
RECONCILIATION_AGENT_DIR := agents/research/reconciliation
1111
PRICEWATCHER_AGENT_DIR := agents/pricewatcher
12+
SENTINEL_AGENT_DIR := agents/sentinel
1213

1314
# Go commands
1415
GOCMD := go
@@ -51,11 +52,12 @@ clean: ## Remove build artifacts
5152
$(GOCLEAN)
5253
rm -rf $(BINARY_DIR)
5354
rm -rf checkpoints
54-
rm -f agents/example/agent.wasm
55-
rm -f agents/example/agent.wasm.checkpoint
55+
rm -f agents/research/example/agent.wasm
56+
rm -f agents/research/example/agent.wasm.checkpoint
5657
rm -f agents/heartbeat/agent.wasm
57-
rm -f agents/reconciliation/agent.wasm
58+
rm -f agents/research/reconciliation/agent.wasm
5859
rm -f agents/pricewatcher/agent.wasm
60+
rm -f agents/sentinel/agent.wasm
5961
@echo "Clean complete"
6062

6163
test: ## Run tests (with race detector)
@@ -127,10 +129,17 @@ agent-pricewatcher: ## Build price watcher demo agent WASM
127129
cd $(PRICEWATCHER_AGENT_DIR) && $(MAKE) build
128130
@echo "Agent built: $(PRICEWATCHER_AGENT_DIR)/agent.wasm"
129131

132+
agent-sentinel: ## Build treasury sentinel demo agent WASM
133+
@echo "Building sentinel agent..."
134+
@which tinygo > /dev/null || \
135+
(echo "tinygo not found. See docs/governance/DEVELOPMENT.md for installation" && exit 1)
136+
cd $(SENTINEL_AGENT_DIR) && $(MAKE) build
137+
@echo "Agent built: $(SENTINEL_AGENT_DIR)/agent.wasm"
138+
130139
demo: build agent-reconciliation ## Build and run reconciliation demo
131140
@echo "Building demo runner..."
132141
@mkdir -p $(BINARY_DIR)
133-
$(GOBUILD) -o $(BINARY_DIR)/demo-reconciliation ./cmd/demo-reconciliation
142+
$(GOBUILD) -o $(BINARY_DIR)/demo-reconciliation ./agents/research/reconciliation/cmd/demo
134143
@echo "Running Bridge Reconciliation Demo..."
135144
./$(BINARY_DIR)/demo-reconciliation --wasm $(RECONCILIATION_AGENT_DIR)/agent.wasm
136145

@@ -144,6 +153,11 @@ demo-pricewatcher: build agent-pricewatcher ## Run the price watcher demo (fetch
144153
@chmod +x scripts/demo-pricewatcher.sh
145154
@./scripts/demo-pricewatcher.sh
146155

156+
demo-sentinel: build agent-sentinel ## Run the treasury sentinel demo (effect lifecycle, crash recovery)
157+
@echo "Running Treasury Sentinel Demo..."
158+
@chmod +x scripts/demo-sentinel.sh
159+
@./scripts/demo-sentinel.sh
160+
147161
check: fmt-check vet lint test ## Run all checks (formatting, vet, lint, tests)
148162
@echo "All checks passed"
149163

agents/reconciliation/go.mod

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ make agent # from repo root
6868

6969
```bash
7070
make run-agent # default budget 1.0
71-
./bin/igord --run-agent agents/example/agent.wasm --budget 10.0
71+
./bin/igord --run-agent agents/research/example/agent.wasm --budget 10.0
7272
```
7373

7474
## Demonstrating Survival
7575

7676
```bash
7777
# Start the agent
78-
./bin/igord --run-agent agents/example/agent.wasm --budget 10.0
78+
./bin/igord --run-agent agents/research/example/agent.wasm --budget 10.0
7979

8080
# Let it tick a few times, then Ctrl-C (checkpoints on shutdown)
8181

8282
# Restart — it resumes from checkpoint, tick count and age continue
83-
./bin/igord --run-agent agents/example/agent.wasm --budget 10.0
83+
./bin/igord --run-agent agents/research/example/agent.wasm --budget 10.0
8484
```
File renamed without changes.

agents/research/example/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module github.com/simonovic86/igor/agents/research/example
2+
3+
go 1.24
4+
5+
require github.com/simonovic86/igor/sdk/igor v0.0.0
6+
7+
replace github.com/simonovic86/igor/sdk/igor => ../../../sdk/igor

0 commit comments

Comments
 (0)