Early Technical Insights (from Peago Phase)
Technical concepts from the early “Peago” design phase that may still be relevant for Amigos.
Transpiler Architecture
Original Vision
// .peago file (source)
package myapp
var counter int // Persistent by default
func Increment() {
counter++ // Auto-persisted
}
// Transpiles to .pea.go
package myapp
import "peago/runtime"
var counter = runtime.State[int]("counter")
func Increment() {
counter.Update(func(val int) int {
return val + 1
})
}
Insights for Amigos
- Transpilation allows pure Go syntax
- State persistence can be automatic
- Developer experience prioritized over runtime complexity
Copy-on-Write State Design
COW Storage Model
State Version Tree:
├── v1: Initial state
├── v2: After first write
│ └── Only changed values stored
├── v3: After second write
│ └── Delta from v2
└── HEAD: Current state
Benefits Identified
- Efficient storage (only deltas)
- Natural versioning
- Easy rollback/fork
- Time-travel debugging
Universal Import Resolution
Import Syntax Unification
// All these work the same way:
import "local/package" // Local file
import "github.com/user/repo" // GitHub
import "chain.com/contract" // Blockchain
import "ipfs://Qm..." // IPFS
Resolution Strategy
- Check local cache first
- Resolve via appropriate protocol
- Verify integrity/signatures
- Cache for offline use
Contract-First Philosophy
Everything as Contracts
// Even config is a contract
type Config struct {
Port int
Host string
}
// Configs can import other configs
import baseConfig "company/standard-config"
var config = Config{
baseConfig.Config,
Port: 8080, // Override
}
Design Implications
- No distinction between code/config/data
- Everything versionable
- Everything importable
- Everything forkable
State Synchronization Ideas
Multi-Master Sync
Node A: State v1 → v2 → v3
↘
Merge → v4
↗
Node B: State v1 → v2'
Conflict Resolution
- Last-write-wins for simple types
- CRDT for collections
- Custom merge functions
- User-defined conflict handlers
Testing Philosophy
State-Aware Testing
func TestCounter(t *testing.T) {
// Each test gets fresh state
state.Reset()
Increment()
assert.Equal(t, 1, counter)
// Can test state persistence
state.Save()
state.Reset()
state.Load()
assert.Equal(t, 1, counter)
}
Test Scenarios
- Ephemeral mode testing
- State persistence testing
- Fork testing
- Import resolution testing
Rendering System Design
Automatic UI Generation
type TodoList struct {
Items []string
}
// Auto-generates UI
func (t TodoList) Render() string {
// Default HTML rendering
}
// Custom rendering
func (t TodoList) RenderMobile() string {
// Mobile-specific UI
}
Security Considerations (Early Thoughts)
State Isolation
- Each contract has isolated state namespace
- Explicit permissions for state sharing
- Capability-based security model
Resource Limits
// Proposed annotations
//go:peago maxstate=1GB
//go:peago maxcompute=1000ms
package myapp
Developer Experience Goals
Zero Configuration
- No database setup
- No API definitions
- No serialization code
- No deployment configs
Progressive Complexity
- Start with simple Go
- Add persistence with one import
- Scale to blockchain when ready
Deprecated Ideas
Package Suffixes (.peago)
- Now: Standard .go files work
- Reasoning: Reduce learning curve
Custom Standard Library
- Now: Use standard Go interfaces
- Reasoning: Maintain compatibility
Explicit State Markers
- Was:
var counter int //persistent - Now: All package-level state persists
- Reasoning: Simpler mental model
Valuable Concepts to Preserve
- COW Storage - Still relevant for efficiency
- Universal Imports - Core to Amigos vision
- Everything as Contracts - Unified model
- State Versioning - Git for state
- Zero Config - Critical for adoption
Integration with Current Design
These early insights should inform:
- VM implementation details
- State storage optimization
- Import system architecture
- Developer experience design
- Testing framework design
The Peago phase established key principles that remain central to Amigos: simplicity, universality, and persistence by default.
Sources
- Early Peago Notes: https://gist.github.com/moul/0203106b17976421378a8ea92133dc96 - Initial technical brainstorming for what became Amigos