9580f347c6
Implements Phase 2 of v0.1 Foundation:
- internal/model/node.go: Node struct with state machine (pending/ready/left)
- internal/store/store.go: SQLite open with WAL + foreign_keys pragmas
- internal/store/migrate.go: embedded SQL migration runner
- internal/store/migrations/0001_nodes.sql: nodes table schema
- internal/store/node_repo.go: CRUD operations for nodes
- internal/store/node_repo_test.go: 4 tests covering insert/get/list/update/delete
- internal/engine/registry.go: in-memory wrapper with slog audit logging
- internal/cli/node.go: orca node {join,leave,list} wired to registry
Verified: node join/list/leave work end-to-end, JSON output, slog audit logs,
state persists in SQLite, all tests pass with -race.
---ci---
project: orca
phase: 2
milestone: v0.1
status: execute
req_covered:
- REQ-002
- REQ-005
- REQ-008
- REQ-012
- REQ-017
- REQ-018
---/ci---
22 lines
520 B
Go
22 lines
520 B
Go
package model
|
|
|
|
import "time"
|
|
|
|
type NodeState string
|
|
|
|
const (
|
|
NodeStatePending NodeState = "pending"
|
|
NodeStateReady NodeState = "ready"
|
|
NodeStateLeft NodeState = "left"
|
|
)
|
|
|
|
type Node struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
Address string `json:"address"`
|
|
State NodeState `json:"state"`
|
|
JoinedAt time.Time `json:"joined_at"`
|
|
LastSeen time.Time `json:"last_seen"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
}
|