Entities.vala 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. using InvercargillSql.Orm;
  2. namespace ClankerSaddle.Data {
  3. /**
  4. * A software project worked on by saddle agents, stored in the
  5. * `projects` table.
  6. */
  7. public class Project : Object {
  8. public int64 id { get; set; }
  9. public string name { get; set; default = ""; }
  10. public string git_url { get; set; default = ""; }
  11. public string default_branch { get; set; default = "main"; }
  12. public string? summary { get; set; default = null; }
  13. public DateTime? created_at { get; set; default = null; }
  14. public static void entity_mapping(EntityMapperBuilder<Project> cfg) {
  15. cfg.table("projects")
  16. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  17. .column<string>("name", o => o.name, (o, v) => o.name = v)
  18. .column<string>("git_url", o => o.git_url, (o, v) => o.git_url = v)
  19. .column<string>("default_branch", o => o.default_branch, (o, v) => o.default_branch = v)
  20. .column<string>("summary", o => o.summary, (o, v) => o.summary = v)
  21. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  22. }
  23. }
  24. /**
  25. * A directed relationship between two projects ('co-developed' or
  26. * 'reference'), stored in the `project_links` table.
  27. */
  28. public class ProjectLink : Object {
  29. public int64 id { get; set; }
  30. public int64 parent_project_id { get; set; }
  31. public int64 linked_project_id { get; set; }
  32. public string relationship { get; set; default = "reference"; }
  33. public static void entity_mapping(EntityMapperBuilder<ProjectLink> cfg) {
  34. cfg.table("project_links")
  35. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  36. .column<int64?>("parent_project_id", o => o.parent_project_id, (o, v) => o.parent_project_id = v)
  37. .column<int64?>("linked_project_id", o => o.linked_project_id, (o, v) => o.linked_project_id = v)
  38. .column<string>("relationship", o => o.relationship, (o, v) => o.relationship = v);
  39. }
  40. }
  41. /**
  42. * A unit of work for a saddle agent: created in {@link
  43. * TaskService.STATUS_DRAFT}, queued by its creator (human or goal
  44. * agent), dispatched to a saddle, worked, possibly blocked on
  45. * questions, and eventually done or failed (completion is
  46. * agent-only). The plan-12 shape: goals own the task graph — a task
  47. * links its {@link goal_id}, runs as a plain worker or the goal
  48. * agent itself ({@link kind}), carries a work {@link mode} and its
  49. * {@link creator}, and human tasks may carry an auto-enqueue
  50. * predecessor ({@link enqueue_after_task_id}). Stored in the
  51. * `tasks` table. Named `TaskEntity` (not `Task`) to stay clear of
  52. * `GLib.Task` in files that import Gio transitively.
  53. */
  54. public class TaskEntity : Object {
  55. public int64 id { get; set; }
  56. public int64 project_id { get; set; }
  57. public string title { get; set; default = ""; }
  58. public string? description { get; set; default = null; }
  59. public string status { get; set; default = "draft"; }
  60. public int64 priority { get; set; default = 5; }
  61. public string? summary { get; set; default = null; }
  62. public string? task_branch { get; set; default = null; }
  63. public string? branch_from { get; set; default = null; }
  64. public DateTime? created_at { get; set; default = null; }
  65. public DateTime? started_at { get; set; default = null; }
  66. public DateTime? completed_at { get; set; default = null; }
  67. public DateTime? suspended_at { get; set; default = null; }
  68. /**
  69. * Goal 4 task 1 (Force Wake): the human pressed Force wake on
  70. * the task page — this suspended plain task becomes
  71. * parked-offerable again with the explicit wake notice.
  72. * Consumed (cleared) by the allocation that resumes it.
  73. */
  74. public bool force_wake { get; set; default = false; }
  75. /** The goal this task belongs to (0 = standalone). */
  76. public int64 goal_id { get; set; default = 0; }
  77. /** "task" (a worker) or "goal_run" (the goal agent's own run). */
  78. public string kind { get; set; default = "task"; }
  79. /** implement / investigate / review / test (orchestrate for goal runs). */
  80. public string mode { get; set; default = "implement"; }
  81. /** "human" or "goal" — enqueueing is creator-only. */
  82. public string creator { get; set; default = "human"; }
  83. /** Human-created tasks only: auto-enqueue when this predecessor is done. */
  84. public int64 enqueue_after_task_id { get; set; default = 0; }
  85. public static void entity_mapping(EntityMapperBuilder<TaskEntity> cfg) {
  86. cfg.table("tasks")
  87. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  88. .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
  89. .column<string>("title", o => o.title, (o, v) => o.title = v)
  90. .column<string>("description", o => o.description, (o, v) => o.description = v)
  91. .column<string>("status", o => o.status, (o, v) => o.status = v)
  92. .column<int64?>("priority", o => o.priority, (o, v) => o.priority = v)
  93. .column<string>("summary", o => o.summary, (o, v) => o.summary = v)
  94. .column<string>("task_branch", o => o.task_branch, (o, v) => o.task_branch = v)
  95. .column<string>("branch_from", o => o.branch_from, (o, v) => o.branch_from = v)
  96. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v)
  97. .column<DateTime?>("started_at", o => o.started_at, (o, v) => o.started_at = v)
  98. .column<DateTime?>("completed_at", o => o.completed_at, (o, v) => o.completed_at = v)
  99. .column<DateTime?>("suspended_at", o => o.suspended_at, (o, v) => o.suspended_at = v)
  100. .column<bool>("force_wake", o => o.force_wake, (o, v) => o.force_wake = v)
  101. .column<int64?>("goal_id", o => o.goal_id, (o, v) => o.goal_id = v ?? 0)
  102. .column<string>("kind", o => o.kind, (o, v) => o.kind = v)
  103. .column<string>("mode", o => o.mode, (o, v) => o.mode = v)
  104. .column<string>("creator", o => o.creator, (o, v) => o.creator = v)
  105. .column<int64?>("enqueue_after_task_id", o => o.enqueue_after_task_id, (o, v) => o.enqueue_after_task_id = v ?? 0);
  106. }
  107. }
  108. /**
  109. * One row of the plan-17 unified event ledger (`events`): daemon
  110. * events carry their session and its per-session monotonic `seq`
  111. * (the idempotency key), web-originated events carry neither. The
  112. * payload is a JSON object whose shape depends on `kind` (see
  113. * Services.EventService).
  114. */
  115. public class EventRecord : Object {
  116. public int64 id { get; set; }
  117. public int64 session_id { get; set; default = 0; }
  118. public int64 seq { get; set; default = 0; }
  119. public string kind { get; set; default = ""; }
  120. public string actor { get; set; default = ""; }
  121. public string scope_type { get; set; default = ""; }
  122. public int64 scope_id { get; set; }
  123. public string payload { get; set; default = "{}"; }
  124. public DateTime? created_at { get; set; default = null; }
  125. public static void entity_mapping(EntityMapperBuilder<EventRecord> cfg) {
  126. cfg.table("events")
  127. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  128. .column<int64?>("session_id",
  129. o => o.session_id > 0 ? (int64?) o.session_id : (int64?) null,
  130. (o, v) => o.session_id = v ?? 0)
  131. .column<int64?>("seq",
  132. o => o.seq > 0 ? (int64?) o.seq : (int64?) null,
  133. (o, v) => o.seq = v ?? 0)
  134. .column<string>("kind", o => o.kind, (o, v) => o.kind = v)
  135. .column<string>("actor", o => o.actor, (o, v) => o.actor = v)
  136. .column<string>("scope_type", o => o.scope_type, (o, v) => o.scope_type = v)
  137. .column<int64?>("scope_id", o => o.scope_id, (o, v) => o.scope_id = v ?? 0)
  138. .column<string>("payload", o => o.payload, (o, v) => o.payload = v)
  139. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  140. }
  141. }
  142. /** A remark on a task, authored either by a human or by the agent ('agent'). */
  143. public class TaskComment : Object {
  144. public int64 id { get; set; }
  145. public int64 task_id { get; set; }
  146. public string author { get; set; default = "agent"; }
  147. public string body { get; set; default = ""; }
  148. public string? quote { get; set; default = null; }
  149. public DateTime? created_at { get; set; default = null; }
  150. public static void entity_mapping(EntityMapperBuilder<TaskComment> cfg) {
  151. cfg.table("task_comments")
  152. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  153. .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
  154. .column<string>("author", o => o.author, (o, v) => o.author = v)
  155. .column<string>("body", o => o.body, (o, v) => o.body = v)
  156. .column<string>("quote", o => o.quote, (o, v) => o.quote = v)
  157. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  158. }
  159. }
  160. /**
  161. * A blocking prompt raised by an agent mid-task — a multiple-choice
  162. * {@link block_type} question, a request for comment or a review
  163. * request — answered by a human in the web UI; the answer is collected
  164. * by the saddle on its next
  165. * {@link ClankerSaddle.Services.SaddlePollState} delivery ledger poll.
  166. */
  167. public class TaskBlock : Object {
  168. public int64 id { get; set; }
  169. public int64 task_id { get; set; }
  170. public string question { get; set; default = ""; }
  171. public string? answer { get; set; default = null; }
  172. public string block_type { get; set; default = "question"; }
  173. public string? options { get; set; default = null; }
  174. public string? body { get; set; default = null; }
  175. public DateTime? answered_at { get; set; default = null; }
  176. public string? answered_by { get; set; default = null; }
  177. public DateTime? created_at { get; set; default = null; }
  178. public static void entity_mapping(EntityMapperBuilder<TaskBlock> cfg) {
  179. cfg.table("task_blocks")
  180. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  181. .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
  182. .column<string>("question", o => o.question, (o, v) => o.question = v)
  183. .column<string>("answer", o => o.answer, (o, v) => o.answer = v)
  184. .column<string>("type", o => o.block_type, (o, v) => o.block_type = v)
  185. .column<string>("options", o => o.options, (o, v) => o.options = v)
  186. .column<string>("body", o => o.body, (o, v) => o.body = v)
  187. .column<DateTime?>("answered_at", o => o.answered_at, (o, v) => o.answered_at = v)
  188. .column<string>("answered_by", o => o.answered_by, (o, v) => o.answered_by = v)
  189. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  190. }
  191. }
  192. /**
  193. * A saddle container registered with this app: one daemon managing one
  194. * bash session at a time, controlled over HTTP at {@link host}. The
  195. * per-saddle token ({@link token}, plan 10) authorises every
  196. * daemon→web call; removing the row revokes it. Plan 16 item 23:
  197. * sessions are the source of truth for "who runs what" — busy/idle
  198. * are DERIVED (busy iff an open session on an assigned/working task
  199. * exists; see {@link Services.SaddleService.current_work_view}) and
  200. * the row's `status` column is only the OFFLINE probe state
  201. * ('offline' vs 'idle'): the poller's unreachable stamp, cleared by
  202. * a successful probe or a proof-of-life ask. The former
  203. * `current_task_id`/`allocated_at` cache columns are gone.
  204. */
  205. public class Saddle : Object {
  206. public int64 id { get; set; }
  207. public string name { get; set; default = ""; }
  208. public string host { get; set; default = ""; }
  209. public string status { get; set; default = "idle"; }
  210. public string? git_name { get; set; default = null; }
  211. public string? git_email { get; set; default = null; }
  212. public string? ssh_public_key { get; set; default = null; }
  213. public string? token { get; set; default = null; }
  214. public static void entity_mapping(EntityMapperBuilder<Saddle> cfg) {
  215. cfg.table("saddles")
  216. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  217. .column<string>("name", o => o.name, (o, v) => o.name = v)
  218. .column<string>("host", o => o.host, (o, v) => o.host = v)
  219. .column<string>("status", o => o.status, (o, v) => o.status = v)
  220. .column<string>("git_name", o => o.git_name, (o, v) => o.git_name = v)
  221. .column<string>("git_email", o => o.git_email, (o, v) => o.git_email = v)
  222. .column<string>("ssh_public_key", o => o.ssh_public_key, (o, v) => o.ssh_public_key = v)
  223. .column<string>("token", o => o.token, (o, v) => o.token = v);
  224. }
  225. }
  226. /**
  227. * One run of a task on a saddle: opened when the dispatcher assigns
  228. * the task, closed with an outcome when the session ends.
  229. */
  230. public class Session : Object {
  231. public int64 id { get; set; }
  232. public int64 task_id { get; set; }
  233. public int64 saddle_id { get; set; }
  234. public DateTime? started_at { get; set; default = null; }
  235. public DateTime? ended_at { get; set; default = null; }
  236. public string? outcome { get; set; default = null; }
  237. /**
  238. * What a resumed session's agent first received (plan 14 B4):
  239. * the resume_notice the allocation built, stored on the row at
  240. * resume-allocation; null for fresh sessions.
  241. */
  242. public string? resume_notice { get; set; default = null; }
  243. public static void entity_mapping(EntityMapperBuilder<Session> cfg) {
  244. cfg.table("sessions")
  245. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  246. .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
  247. .column<int64?>("saddle_id", o => o.saddle_id, (o, v) => o.saddle_id = v)
  248. .column<DateTime?>("started_at", o => o.started_at, (o, v) => o.started_at = v)
  249. .column<DateTime?>("ended_at", o => o.ended_at, (o, v) => o.ended_at = v)
  250. .column<string>("outcome", o => o.outcome, (o, v) => o.outcome = v)
  251. .column<string>("resume_notice", o => o.resume_notice, (o, v) => o.resume_notice = v);
  252. }
  253. }
  254. /**
  255. * A reusable instruction the dispatched agent must follow, stored in
  256. * the `rules` table and attached to projects and/or tasks.
  257. * `updated_at` stamps the last body/name edit (null until edited)
  258. * — the resume-time context_update delta keys on it.
  259. */
  260. public class Rule : Object {
  261. public int64 id { get; set; }
  262. public string name { get; set; default = ""; }
  263. public string body { get; set; default = ""; }
  264. public DateTime? created_at { get; set; default = null; }
  265. public DateTime? updated_at { get; set; default = null; }
  266. public static void entity_mapping(EntityMapperBuilder<Rule> cfg) {
  267. cfg.table("rules")
  268. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  269. .column<string>("name", o => o.name, (o, v) => o.name = v)
  270. .column<string>("body", o => o.body, (o, v) => o.body = v)
  271. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v)
  272. .column<DateTime?>("updated_at", o => o.updated_at, (o, v) => o.updated_at = v);
  273. }
  274. }
  275. /** An attachment of a rule to a project (`rule_projects`). */
  276. public class RuleProject : Object {
  277. public int64 id { get; set; }
  278. public int64 rule_id { get; set; }
  279. public int64 project_id { get; set; }
  280. public DateTime? created_at { get; set; default = null; }
  281. public static void entity_mapping(EntityMapperBuilder<RuleProject> cfg) {
  282. cfg.table("rule_projects")
  283. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  284. .column<int64?>("rule_id", o => o.rule_id, (o, v) => o.rule_id = v)
  285. .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
  286. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  287. }
  288. }
  289. /** An attachment of a rule to a task (`task_rules`). */
  290. public class TaskRule : Object {
  291. public int64 id { get; set; }
  292. public int64 rule_id { get; set; }
  293. public int64 task_id { get; set; }
  294. public DateTime? created_at { get; set; default = null; }
  295. public static void entity_mapping(EntityMapperBuilder<TaskRule> cfg) {
  296. cfg.table("task_rules")
  297. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  298. .column<int64?>("rule_id", o => o.rule_id, (o, v) => o.rule_id = v)
  299. .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
  300. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  301. }
  302. }
  303. /**
  304. * An LLM-authored remark about a project (`saddle note` via the
  305. * callback endpoint), curated from the project page. The source task
  306. * is null for notes without one.
  307. */
  308. public class ProjectNote : Object {
  309. public int64 id { get; set; }
  310. public int64 project_id { get; set; }
  311. public int64 source_task_id { get; set; default = 0; }
  312. public string body { get; set; default = ""; }
  313. public DateTime? created_at { get; set; default = null; }
  314. public static void entity_mapping(EntityMapperBuilder<ProjectNote> cfg) {
  315. cfg.table("project_notes")
  316. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  317. .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
  318. .column<int64?>("source_task_id", o => o.source_task_id, (o, v) => o.source_task_id = v ?? 0)
  319. .column<string>("body", o => o.body, (o, v) => o.body = v)
  320. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  321. }
  322. }
  323. /**
  324. * A named tag used for dispatch routing (`capabilities`): saddles
  325. * declare the tags they carry, tasks the tags they require.
  326. */
  327. public class Capability : Object {
  328. public int64 id { get; set; }
  329. public string name { get; set; default = ""; }
  330. public DateTime? created_at { get; set; default = null; }
  331. public static void entity_mapping(EntityMapperBuilder<Capability> cfg) {
  332. cfg.table("capabilities")
  333. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  334. .column<string>("name", o => o.name, (o, v) => o.name = v)
  335. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  336. }
  337. }
  338. /** A tag declaration on a saddle (`saddle_capabilities`). */
  339. public class SaddleCapability : Object {
  340. public int64 id { get; set; }
  341. public int64 capability_id { get; set; }
  342. public int64 saddle_id { get; set; }
  343. public static void entity_mapping(EntityMapperBuilder<SaddleCapability> cfg) {
  344. cfg.table("saddle_capabilities")
  345. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  346. .column<int64?>("capability_id", o => o.capability_id, (o, v) => o.capability_id = v)
  347. .column<int64?>("saddle_id", o => o.saddle_id, (o, v) => o.saddle_id = v);
  348. }
  349. }
  350. /** A required tag on a task (`task_capabilities`). */
  351. public class TaskCapability : Object {
  352. public int64 id { get; set; }
  353. public int64 capability_id { get; set; }
  354. public int64 task_id { get; set; }
  355. public static void entity_mapping(EntityMapperBuilder<TaskCapability> cfg) {
  356. cfg.table("task_capabilities")
  357. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  358. .column<int64?>("capability_id", o => o.capability_id, (o, v) => o.capability_id = v)
  359. .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v);
  360. }
  361. }
  362. /**
  363. * A user's Web Push subscription endpoint (plan 11 task E shape):
  364. * `p256dh`/`auth` are the browser's application server keys; the
  365. * endpoint URL is unique per browser. `user_id` references the
  366. * Spry users table by value (no FK — the auth schema owns that
  367. * table).
  368. */
  369. public class PushSubscription : Object {
  370. public int64 id { get; set; }
  371. public int64 user_id { get; set; }
  372. public string endpoint { get; set; default = ""; }
  373. public string p256dh { get; set; default = ""; }
  374. public string auth { get; set; default = ""; }
  375. public DateTime? created_at { get; set; default = null; }
  376. public static void entity_mapping(EntityMapperBuilder<PushSubscription> cfg) {
  377. cfg.table("push_subscriptions")
  378. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  379. .column<int64?>("user_id", o => o.user_id, (o, v) => o.user_id = v)
  380. .column<string>("endpoint", o => o.endpoint, (o, v) => o.endpoint = v)
  381. .column<string>("p256dh", o => o.p256dh, (o, v) => o.p256dh = v)
  382. .column<string>("auth", o => o.auth, (o, v) => o.auth = v)
  383. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
  384. }
  385. }
  386. /**
  387. * A user's per-task "Notify me" opt-in (plan 11 task E shape): the
  388. * task's first start, failure and completion notify the opted-in
  389. * user; block events notify all push-subscribed users globally.
  390. */
  391. public class TaskNotifyPref : Object {
  392. public int64 id { get; set; }
  393. public int64 task_id { get; set; }
  394. public int64 user_id { get; set; }
  395. public static void entity_mapping(EntityMapperBuilder<TaskNotifyPref> cfg) {
  396. cfg.table("task_notify_prefs")
  397. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  398. .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
  399. .column<int64?>("user_id", o => o.user_id, (o, v) => o.user_id = v);
  400. }
  401. }
  402. /**
  403. * A user-created goal (plan 12): an agent-orchestrated unit of
  404. * work over one primary project plus optional links. The brief
  405. * locks once started; the lifecycle runs draft → planning → plan
  406. * review → active → completion review → complete / failed /
  407. * cancelled, with paused freezing supervision in between. Stored
  408. * in the `goals` table.
  409. */
  410. public class Goal : Object {
  411. public int64 id { get; set; }
  412. public int64 project_id { get; set; }
  413. public string title { get; set; default = ""; }
  414. public string brief { get; set; default = ""; }
  415. public string branch_name { get; set; default = ""; }
  416. public string? base_branch { get; set; default = null; }
  417. public string status { get; set; default = "draft"; }
  418. public int64 priority { get; set; default = 3; }
  419. public string? plan { get; set; default = null; }
  420. public string? completion_report { get; set; default = null; }
  421. public string creator { get; set; default = "human"; }
  422. /**
  423. * Plan 15 C3 (was last_seen_event_id): the timestamp through
  424. * which the goal agent has consumed its tasks' terminal
  425. * transitions — resume_due fires on transitions newer than
  426. * it, and a resume advance it. The narrative itself is
  427. * derived at read time.
  428. */
  429. public DateTime? last_terminal_watermark { get; set; default = null; }
  430. public DateTime? created_at { get; set; default = null; }
  431. public DateTime? started_at { get; set; default = null; }
  432. public DateTime? completed_at { get; set; default = null; }
  433. public DateTime? paused_at { get; set; default = null; }
  434. /**
  435. * Goal 4 task 1 (Force Wake): the human pressed Force wake on
  436. * the goal page — the parked run becomes offerable immediately
  437. * and the resume notice leads with the explicit wake line.
  438. * Consumed (cleared) by the resume that carries it.
  439. */
  440. public bool force_wake { get; set; default = false; }
  441. public static void entity_mapping(EntityMapperBuilder<Goal> cfg) {
  442. cfg.table("goals")
  443. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  444. .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
  445. .column<string>("title", o => o.title, (o, v) => o.title = v)
  446. .column<string>("brief", o => o.brief, (o, v) => o.brief = v)
  447. .column<string>("branch_name", o => o.branch_name, (o, v) => o.branch_name = v)
  448. .column<string>("base_branch", o => o.base_branch, (o, v) => o.base_branch = v)
  449. .column<string>("status", o => o.status, (o, v) => o.status = v)
  450. .column<int64?>("priority", o => o.priority, (o, v) => o.priority = v)
  451. .column<string>("plan", o => o.plan, (o, v) => o.plan = v)
  452. .column<string>("completion_report", o => o.completion_report, (o, v) => o.completion_report = v)
  453. .column<string>("creator", o => o.creator, (o, v) => o.creator = v)
  454. .column<DateTime?>("last_terminal_watermark", o => o.last_terminal_watermark, (o, v) => o.last_terminal_watermark = v)
  455. .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v)
  456. .column<DateTime?>("started_at", o => o.started_at, (o, v) => o.started_at = v)
  457. .column<DateTime?>("completed_at", o => o.completed_at, (o, v) => o.completed_at = v)
  458. .column<DateTime?>("paused_at", o => o.paused_at, (o, v) => o.paused_at = v)
  459. .column<bool>("force_wake", o => o.force_wake, (o, v) => o.force_wake = v);
  460. }
  461. }
  462. /** A project link on a goal (`goal_links`): co-developed or reference. */
  463. public class GoalLink : Object {
  464. public int64 id { get; set; }
  465. public int64 goal_id { get; set; }
  466. public int64 project_id { get; set; }
  467. public string relationship { get; set; default = "reference"; }
  468. public static void entity_mapping(EntityMapperBuilder<GoalLink> cfg) {
  469. cfg.table("goal_links")
  470. .column<int64?>("id", o => o.id, (o, v) => o.id = v)
  471. .column<int64?>("goal_id", o => o.goal_id, (o, v) => o.goal_id = v)
  472. .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
  473. .column<string>("relationship", o => o.relationship, (o, v) => o.relationship = v);
  474. }
  475. }
  476. }