types.gno
2.48 Kb · 97 lines
1package agentmarketplace
2
3import "time"
4
5// Rate kinds for an agent's listed price.
6const (
7 RateHourly = "hourly"
8 RateFlat = "flat"
9)
10
11// Task statuses. The escrowed ugnot is held while the task is open or
12// in-progress, then released exactly once on complete or cancel.
13const (
14 StatusOpen = "open"
15 StatusInProgress = "in-progress"
16 StatusCompleted = "completed"
17 StatusCancelled = "cancelled"
18)
19
20// Agent is a registered worker. The caller's address is the agent id
21// and owner; one address can register at most one agent.
22type Agent struct {
23 Owner address
24 Name string
25 Tags string // canonical, comma-space separated specialties
26 RateKind string
27 RateUgnot int64
28 RegisteredAt time.Time
29 Completed int
30 EarnedUgnot int64
31}
32
33// Task is a job posted with an ugnot budget held in escrow by the realm.
34type Task struct {
35 ID int
36 Poster address
37 Title string
38 Description string
39 Specialty string // required specialty tag
40 BudgetUgnot int64
41 Status string
42 PostedAt time.Time
43
44 WinningBidID int
45 Winner address
46 AcceptedAt time.Time
47 CompletedAt time.Time
48 Settled bool // true after payout or refund; prevents double settlement
49
50 // Optional hash-commit settlement. Empty CommitHash means the winning
51 // agent may call CompleteTask as usual. When set, they must reveal a
52 // preimage of this SHA-256 (lowercase hex) before RevealBy.
53 CommitHash string
54 RevealBy time.Time
55}
56
57// Bid is one agent's offer on an open task.
58type Bid struct {
59 ID int
60 TaskID int
61 Agent address
62 Amount int64 // ugnot, must be > 0 and <= the task budget
63 Note string
64 PlacedAt time.Time
65}
66
67// Rating is one poster's 1-5 review of a settled job.
68type Rating struct {
69 ID int
70 TaskID int
71 Agent address
72 Poster address
73 Score int // 1-5
74 Comment string
75 BudgetUgnot int64 // snapshot of the task budget, used as weight
76 ReviewerWt int64 // snapshot of reviewer weight (1000 = 1.0)
77 RatedAt time.Time
78}
79
80// AgentScore is a cached view of an agent's reputation, rebuilt on Rate
81// and RefreshScore. Queries and Render recompute decay live from ratings.
82type AgentScore struct {
83 Agent address
84 RatedCount int
85 TrustMilli int64 // 1000-5000, 0 if unrated
86 RawMilli int64
87 Provisional bool
88 LastRatedAt time.Time
89}
90
91// PosterStats tracks a poster's history, used to grow reviewer weight.
92type PosterStats struct {
93 Owner address
94 SettledJobs int
95 SettledUgnot int64
96 DistinctAgents int
97}