| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- using InvercargillSql.Orm;
- namespace ClankerSaddle.Data {
- /**
- * A software project worked on by saddle agents, stored in the
- * `projects` table.
- */
- public class Project : Object {
- public int64 id { get; set; }
- public string name { get; set; default = ""; }
- public string git_url { get; set; default = ""; }
- public string default_branch { get; set; default = "main"; }
- public string? summary { get; set; default = null; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<Project> cfg) {
- cfg.table("projects")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<string>("name", o => o.name, (o, v) => o.name = v)
- .column<string>("git_url", o => o.git_url, (o, v) => o.git_url = v)
- .column<string>("default_branch", o => o.default_branch, (o, v) => o.default_branch = v)
- .column<string>("summary", o => o.summary, (o, v) => o.summary = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /**
- * A directed relationship between two projects ('co-developed' or
- * 'reference'), stored in the `project_links` table.
- */
- public class ProjectLink : Object {
- public int64 id { get; set; }
- public int64 parent_project_id { get; set; }
- public int64 linked_project_id { get; set; }
- public string relationship { get; set; default = "reference"; }
- public static void entity_mapping(EntityMapperBuilder<ProjectLink> cfg) {
- cfg.table("project_links")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("parent_project_id", o => o.parent_project_id, (o, v) => o.parent_project_id = v)
- .column<int64?>("linked_project_id", o => o.linked_project_id, (o, v) => o.linked_project_id = v)
- .column<string>("relationship", o => o.relationship, (o, v) => o.relationship = v);
- }
- }
- /**
- * A unit of work for a saddle agent: queued, dispatched to a saddle,
- * worked, possibly blocked on questions, and eventually done or failed.
- * Stored in the `tasks` table; child tasks reference their parent via
- * {@link parent_task_id}. Named `TaskEntity` (not `Task`) to stay
- * clear of `GLib.Task` in files that import Gio transitively.
- */
- public class TaskEntity : Object {
- public int64 id { get; set; }
- public int64 parent_task_id { get; set; default = 0; }
- public int64 project_id { get; set; }
- public string title { get; set; default = ""; }
- public string? description { get; set; default = null; }
- public string status { get; set; default = "queued"; }
- public int64 priority { get; set; default = 5; }
- public bool is_design_task { get; set; default = false; }
- public string? working_branch { get; set; default = null; }
- public string? summary { get; set; default = null; }
- public string? plan { get; set; default = null; }
- public string? task_branch { get; set; default = null; }
- public string? branch_from { get; set; default = null; }
- public DateTime? created_at { get; set; default = null; }
- public DateTime? started_at { get; set; default = null; }
- public DateTime? completed_at { get; set; default = null; }
- public DateTime? suspended_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<TaskEntity> cfg) {
- cfg.table("tasks")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("parent_task_id", o => o.parent_task_id, (o, v) => o.parent_task_id = v)
- .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
- .column<string>("title", o => o.title, (o, v) => o.title = v)
- .column<string>("description", o => o.description, (o, v) => o.description = v)
- .column<string>("status", o => o.status, (o, v) => o.status = v)
- .column<int64?>("priority", o => o.priority, (o, v) => o.priority = v)
- .column<bool>("is_design_task", o => o.is_design_task, (o, v) => o.is_design_task = v)
- .column<string>("working_branch", o => o.working_branch, (o, v) => o.working_branch = v)
- .column<string>("summary", o => o.summary, (o, v) => o.summary = v)
- .column<string>("plan", o => o.plan, (o, v) => o.plan = v)
- .column<string>("task_branch", o => o.task_branch, (o, v) => o.task_branch = v)
- .column<string>("branch_from", o => o.branch_from, (o, v) => o.branch_from = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v)
- .column<DateTime?>("started_at", o => o.started_at, (o, v) => o.started_at = v)
- .column<DateTime?>("completed_at", o => o.completed_at, (o, v) => o.completed_at = v)
- .column<DateTime?>("suspended_at", o => o.suspended_at, (o, v) => o.suspended_at = v);
- }
- }
- /**
- * One LLM-reported progress line on a task (`saddle progress-update`),
- * stored in the `task_progress` table.
- */
- public class TaskProgress : Object {
- public int64 id { get; set; }
- public int64 task_id { get; set; }
- public string summary { get; set; default = ""; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<TaskProgress> cfg) {
- cfg.table("task_progress")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
- .column<string>("summary", o => o.summary, (o, v) => o.summary = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /** An edge saying one task must finish before another may start. */
- public class TaskDependency : Object {
- public int64 id { get; set; }
- public int64 task_id { get; set; }
- public int64 depends_on_task_id { get; set; }
- public static void entity_mapping(EntityMapperBuilder<TaskDependency> cfg) {
- cfg.table("task_dependencies")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
- .column<int64?>("depends_on_task_id", o => o.depends_on_task_id, (o, v) => o.depends_on_task_id = v);
- }
- }
- /** A remark on a task, authored either by a human or by the agent ('bot'). */
- public class TaskComment : Object {
- public int64 id { get; set; }
- public int64 task_id { get; set; }
- public string author { get; set; default = "bot"; }
- public string body { get; set; default = ""; }
- public string? quote { get; set; default = null; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<TaskComment> cfg) {
- cfg.table("task_comments")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
- .column<string>("author", o => o.author, (o, v) => o.author = v)
- .column<string>("body", o => o.body, (o, v) => o.body = v)
- .column<string>("quote", o => o.quote, (o, v) => o.quote = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /**
- * A blocking prompt raised by an agent mid-task — a multiple-choice
- * {@link block_type} question, a request for comment or a review
- * request — answered by a human in the web UI; the answer is collected
- * by the saddle on its next
- * {@link ClankerSaddle.Api.SaddlePollEndpoint} poll.
- */
- public class TaskBlock : Object {
- public int64 id { get; set; }
- public int64 task_id { get; set; }
- public string question { get; set; default = ""; }
- public string? answer { get; set; default = null; }
- public string block_type { get; set; default = "question"; }
- public string? options { get; set; default = null; }
- public string? body { get; set; default = null; }
- public DateTime? answered_at { get; set; default = null; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<TaskBlock> cfg) {
- cfg.table("task_blocks")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
- .column<string>("question", o => o.question, (o, v) => o.question = v)
- .column<string>("answer", o => o.answer, (o, v) => o.answer = v)
- .column<string>("type", o => o.block_type, (o, v) => o.block_type = v)
- .column<string>("options", o => o.options, (o, v) => o.options = v)
- .column<string>("body", o => o.body, (o, v) => o.body = v)
- .column<DateTime?>("answered_at", o => o.answered_at, (o, v) => o.answered_at = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /**
- * A saddle container registered with this app: one daemon managing one
- * bash session at a time, controlled over HTTP at {@link host}.
- */
- public class Saddle : Object {
- public int64 id { get; set; }
- public string name { get; set; default = ""; }
- public string? container_id { get; set; default = null; }
- public string host { get; set; default = ""; }
- public string status { get; set; default = "offline"; }
- public int64 current_task_id { get; set; default = 0; }
- public DateTime? allocated_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<Saddle> cfg) {
- cfg.table("saddles")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<string>("name", o => o.name, (o, v) => o.name = v)
- .column<string>("container_id", o => o.container_id, (o, v) => o.container_id = v)
- .column<string>("host", o => o.host, (o, v) => o.host = v)
- .column<string>("status", o => o.status, (o, v) => o.status = v)
- .column<int64?>("current_task_id", o => o.current_task_id, (o, v) => o.current_task_id = v)
- .column<DateTime?>("allocated_at", o => o.allocated_at, (o, v) => o.allocated_at = v);
- }
- }
- /**
- * One run of a task on a saddle: opened when the dispatcher assigns
- * the task, closed with an outcome when the session ends.
- */
- public class Session : Object {
- public int64 id { get; set; }
- public int64 task_id { get; set; }
- public int64 saddle_id { get; set; }
- public DateTime? started_at { get; set; default = null; }
- public DateTime? ended_at { get; set; default = null; }
- public string? outcome { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<Session> cfg) {
- cfg.table("sessions")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v)
- .column<int64?>("saddle_id", o => o.saddle_id, (o, v) => o.saddle_id = v)
- .column<DateTime?>("started_at", o => o.started_at, (o, v) => o.started_at = v)
- .column<DateTime?>("ended_at", o => o.ended_at, (o, v) => o.ended_at = v)
- .column<string>("outcome", o => o.outcome, (o, v) => o.outcome = v);
- }
- }
- /**
- * A numbered entry captured during a {@link Session} — a bash
- * command/output pair or a conversation-level event (comment, block,
- * progress, review, plan, user-comment) — stored as the saddle daemon
- * reports it.
- */
- public class SessionCommand : Object {
- public int64 id { get; set; }
- public int64 session_id { get; set; }
- public string command_text { get; set; default = ""; }
- public string? output_text { get; set; default = null; }
- public int64 exit_code { get; set; default = 0; }
- public string entry_type { get; set; default = "command"; }
- public string? piped_input { get; set; default = null; }
- public DateTime? started_at { get; set; default = null; }
- public DateTime? completed_at { get; set; default = null; }
- public int64 duration_ms { get; set; default = 0; }
- public static void entity_mapping(EntityMapperBuilder<SessionCommand> cfg) {
- cfg.table("session_commands")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("session_id", o => o.session_id, (o, v) => o.session_id = v)
- .column<string>("command_text", o => o.command_text, (o, v) => o.command_text = v)
- .column<string>("output_text", o => o.output_text, (o, v) => o.output_text = v)
- .column<int64?>("exit_code", o => o.exit_code, (o, v) => o.exit_code = v)
- .column<string>("type", o => o.entry_type, (o, v) => o.entry_type = v)
- .column<string>("piped_input", o => o.piped_input, (o, v) => o.piped_input = v)
- .column<DateTime?>("started_at", o => o.started_at, (o, v) => o.started_at = v)
- .column<DateTime?>("completed_at", o => o.completed_at, (o, v) => o.completed_at = v)
- .column<int64?>("duration_ms", o => o.duration_ms, (o, v) => o.duration_ms = v);
- }
- }
- /**
- * A reusable instruction the dispatched agent must follow, stored in
- * the `rules` table and attached to projects and/or tasks.
- */
- public class Rule : Object {
- public int64 id { get; set; }
- public string name { get; set; default = ""; }
- public string body { get; set; default = ""; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<Rule> cfg) {
- cfg.table("rules")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<string>("name", o => o.name, (o, v) => o.name = v)
- .column<string>("body", o => o.body, (o, v) => o.body = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /** An attachment of a rule to a project (`rule_projects`). */
- public class RuleProject : Object {
- public int64 id { get; set; }
- public int64 rule_id { get; set; }
- public int64 project_id { get; set; }
- public static void entity_mapping(EntityMapperBuilder<RuleProject> cfg) {
- cfg.table("rule_projects")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("rule_id", o => o.rule_id, (o, v) => o.rule_id = v)
- .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v);
- }
- }
- /** An attachment of a rule to a task (`task_rules`). */
- public class TaskRule : Object {
- public int64 id { get; set; }
- public int64 rule_id { get; set; }
- public int64 task_id { get; set; }
- public static void entity_mapping(EntityMapperBuilder<TaskRule> cfg) {
- cfg.table("task_rules")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("rule_id", o => o.rule_id, (o, v) => o.rule_id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v);
- }
- }
- /**
- * An LLM-authored remark about a project (`saddle note` via the
- * callback endpoint), curated from the project page. The source task
- * is null for notes without one.
- */
- public class ProjectNote : Object {
- public int64 id { get; set; }
- public int64 project_id { get; set; }
- public int64 source_task_id { get; set; default = 0; }
- public string body { get; set; default = ""; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<ProjectNote> cfg) {
- cfg.table("project_notes")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("project_id", o => o.project_id, (o, v) => o.project_id = v)
- .column<int64?>("source_task_id", o => o.source_task_id, (o, v) => o.source_task_id = v ?? 0)
- .column<string>("body", o => o.body, (o, v) => o.body = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /**
- * One raw PTY output chunk of a {@link Session}, pulled from the
- * daemon's `GET /log` ring buffer while the session is active
- * (`session_raw_log`); `seq` is the daemon's monotonic chunk
- * sequence number.
- */
- public class SessionRawLog : Object {
- public int64 id { get; set; }
- public int64 session_id { get; set; }
- public int64 seq { get; set; }
- public string chunk { get; set; default = ""; }
- public static void entity_mapping(EntityMapperBuilder<SessionRawLog> cfg) {
- cfg.table("session_raw_log")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("session_id", o => o.session_id, (o, v) => o.session_id = v)
- .column<int64?>("seq", o => o.seq, (o, v) => o.seq = v)
- .column<string>("chunk", o => o.chunk, (o, v) => o.chunk = v);
- }
- }
- /**
- * A named tag used for dispatch routing (`capabilities`): saddles
- * declare the tags they carry, tasks the tags they require.
- */
- public class Capability : Object {
- public int64 id { get; set; }
- public string name { get; set; default = ""; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<Capability> cfg) {
- cfg.table("capabilities")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<string>("name", o => o.name, (o, v) => o.name = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- /** A tag declaration on a saddle (`saddle_capabilities`). */
- public class SaddleCapability : Object {
- public int64 id { get; set; }
- public int64 capability_id { get; set; }
- public int64 saddle_id { get; set; }
- public static void entity_mapping(EntityMapperBuilder<SaddleCapability> cfg) {
- cfg.table("saddle_capabilities")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("capability_id", o => o.capability_id, (o, v) => o.capability_id = v)
- .column<int64?>("saddle_id", o => o.saddle_id, (o, v) => o.saddle_id = v);
- }
- }
- /** A required tag on a task (`task_capabilities`). */
- public class TaskCapability : Object {
- public int64 id { get; set; }
- public int64 capability_id { get; set; }
- public int64 task_id { get; set; }
- public static void entity_mapping(EntityMapperBuilder<TaskCapability> cfg) {
- cfg.table("task_capabilities")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("capability_id", o => o.capability_id, (o, v) => o.capability_id = v)
- .column<int64?>("task_id", o => o.task_id, (o, v) => o.task_id = v);
- }
- }
- /**
- * A bearer token authorising one saddle daemon's calls against the
- * `/api/saddle/*` endpoints, generated at registration.
- */
- public class ApiToken : Object {
- public int64 id { get; set; }
- public int64 saddle_id { get; set; }
- public string token { get; set; default = ""; }
- public DateTime? created_at { get; set; default = null; }
- public static void entity_mapping(EntityMapperBuilder<ApiToken> cfg) {
- cfg.table("api_tokens")
- .column<int64?>("id", o => o.id, (o, v) => o.id = v)
- .column<int64?>("saddle_id", o => o.saddle_id, (o, v) => o.saddle_id = v)
- .column<string>("token", o => o.token, (o, v) => o.token = v)
- .column<DateTime?>("created_at", o => o.created_at, (o, v) => o.created_at = v);
- }
- }
- }
|