Quellcode durchsuchen

r1: dead code deletion — has_yeehaw (the batch yeehaw_task_ids/yeehaw_feed own every surface), SaddleService snippet_text + generate_token (mint_saddle_token is the live minter), the Saddle.container_id column (entity + flattened M0001, tear-down convention), the never-set 'recovering' branch of unreachable_task_ids, TaskDetailPublic plan/auto_approve/toggle_auto_approve, the duplicated hideQuoteUi in main.html (the activeHandler-clearing definition wins), and the malformed/duplicated docblocks (TaskService nested /**, the orphaned list_tasks header, the SaddleService /status orphan, the TasksEntrypoint double header). fail_goal's empty cascaded-if dies with the counter, the shared cascade_goal_tasks helper owning the cancel/fail task sweep.

clanker vor 1 Monat
Ursprung
Commit
37508060cf

+ 0 - 2
src/Data/Entities.vala

@@ -196,7 +196,6 @@ namespace ClankerSaddle.Data {
 
         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; }
@@ -210,7 +209,6 @@ namespace ClankerSaddle.Data {
             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)

+ 0 - 1
src/Data/Migrations/M0001_Initial.vala

@@ -238,7 +238,6 @@ namespace ClankerSaddle.Data.Migrations {
                     .primary_key();
                 t.column<string>("name")
                     .not_null();
-                t.column<string>("container_id");
                 t.column<string>("host")
                     .not_null();
                 t.column<string>("status")

+ 13 - 18
src/Services/GoalService.vala

@@ -342,6 +342,18 @@ namespace ClankerSaddle.Services {
             ((!)goal).completed_at = new DateTime.now_local();
             yield db.update_async<Goal>((!)goal);
 
+            yield cascade_goal_tasks(goal_id);
+            yield pulse.bump(0, "goal cancelled");
+        }
+
+        /**
+         * The cancel/fail cascade the terminal goal paths share: every
+         * non-terminal task under the goal closes — drafts are deleted
+         * (they never ran; plan 13 B3 — no orphan stays dispatchable),
+         * everything else is cancelled (the running goal agent
+         * included). Terminal rows keep their first outcome.
+         */
+        private async void cascade_goal_tasks(int64 goal_id) throws Error {
             foreach (var task in yield db.query<TaskEntity>()
                     .where(expr("goal_id == $0", elem<int64?>(goal_id)))
                     .order_by(expr("id"))
@@ -355,7 +367,6 @@ namespace ClankerSaddle.Services {
                     yield tasks.cancel_task(task.id);
                 }
             }
-            yield pulse.bump(0, "goal cancelled");
         }
 
         // ------------------------------------------------------------------
@@ -480,23 +491,7 @@ namespace ClankerSaddle.Services {
             // Plan 13 B3: the failure cascade — the cancel-cascade
             // semantics (the run task just failed above, so the loop's
             // terminal skip covers it).
-            int64 cascaded = 0;
-            foreach (var task in yield db.query<TaskEntity>()
-                    .where(expr("goal_id == $0", elem<int64?>(goal_id)))
-                    .order_by(expr("id"))
-                    .materialise_async()) {
-                if (task.status == STATUS_DONE || task.status == STATUS_FAILED) {
-                    continue;
-                }
-                if (task.status == STATUS_DRAFT) {
-                    yield tasks.delete_task_quietly(task.id);
-                } else {
-                    yield tasks.cancel_task(task.id);
-                }
-                cascaded++;
-            }
-            if (cascaded > 0) {
-            }
+            yield cascade_goal_tasks(goal_id);
             push.notify_global(PushService.goal_terminal_notification(
                 ((!)goal).title, goal_id, false));
             yield pulse.bump(0, "goal failed");

+ 0 - 25
src/Services/SaddleService.vala

@@ -184,21 +184,6 @@ namespace ClankerSaddle.Services {
             }
         }
 
-        /**
-          * Generates and stores a fresh API token for `saddle_id`,
-          * replacing any earlier one on the wire (older rows remain valid
-          * until removed; in practice each saddle holds one).
-          */
-        public async string generate_token(int64 saddle_id) throws Error {
-            var row = new ApiToken() {
-                saddle_id = saddle_id,
-                token = @"saddle-$(Uuid.string_random().replace("-", ""))",
-                created_at = new DateTime.now_local()
-            };
-            yield db.insert_async<ApiToken>(row);
-            return row.token;
-        }
-
         /**
          * True when `token` matches the credential of `saddle_id` — its
          * per-saddle row token (plan 10), or any legacy `api_tokens`
@@ -349,10 +334,6 @@ namespace ClankerSaddle.Services {
                 .materialise_async();
         }
 
-        /**
-         * Records a /status observation into the health snapshot,
-         * tolerating older daemons without the uptime/activity fields.
-         */
         /**
          * Persists the saddle's git identity — what its daemon commits
          * as (`git_identity` in every /start). Empty/null clears the
@@ -1376,12 +1357,6 @@ namespace ClankerSaddle.Services {
                 ? ((!)task).goal_id : 0;
         }
 
-        /** A one-line snippet of a body (narrative event text). */
-        private static string snippet_text(string body) {
-            string flat = body.replace("\n", " ").strip();
-            return flat.length > 160 ? flat.substring(0, 160) + "…" : flat;
-        }
-
         /**
          * Raises the daemon's pushed blocking prompt as a `task_blocks`
          * row exactly once: a not-yet-answered row, or an answered row

+ 5 - 24
src/Services/TaskService.vala

@@ -257,10 +257,6 @@ namespace ClankerSaddle.Services {
             };
         }
 
-        /**
-         * Lists tasks, optionally filtered by status and/or project, ordered
-         * by priority (1 first) then creation time.
-         */
         /**
          * Computed display states for a batch of tasks (all lists share
          * this), keyed by task id string. Unanswered review blocks load
@@ -332,6 +328,10 @@ namespace ClankerSaddle.Services {
             return TaskDisplay.compute(detail.task, review_pending, goal_review_pending);
         }
 
+        /**
+         * Lists tasks, optionally filtered by status and/or project, ordered
+         * by priority (1 first) then creation time.
+         */
         public async ImmutableLot<TaskEntity> list_tasks(string? status, int64? project_id) throws Error {
             var tasks = yield db.query<TaskEntity>().materialise_async();
             var rows = new Vector<TaskEntity>();
@@ -744,23 +744,6 @@ namespace ClankerSaddle.Services {
                 .materialise_async();
         }
 
-        /**
-         * True when any of the task's sessions carries a `yeehaw` entry —
-         * the badge's presence check, one cheap EXISTS over the existing
-         * `session_commands` rows (nothing new is stored for the badge).
-         */
-        public async bool has_yeehaw(int64 task_id) throws Error {
-            var command = connection.create_command(
-                "SELECT EXISTS(SELECT 1 FROM session_commands sc"
-                + " JOIN sessions s ON s.id = sc.session_id"
-                + " WHERE s.task_id = :task AND sc.type = :kind) AS hit");
-            command.with_parameter<Invercargill.Element>("task", elem<int64?>(task_id));
-            command.with_parameter<Invercargill.Element>("kind", elem(ENTRY_YEEHAW));
-            var hit = yield command.execute_scalar_async();
-            int64? value = 0;
-            return hit != null && hit.try_get_as<int64?>(out value) && ((!)value) != 0;
-        }
-
         /**
          * Every task id whose sessions carry a `yeehaw` entry (stringly
          * keyed) — the batch presence check the task list and the
@@ -1099,8 +1082,7 @@ namespace ClankerSaddle.Services {
                     var saddle = yield db.query<Saddle>()
                         .where(expr("id == $0", elem<int64?>(((!)session).saddle_id)))
                         .first_async();
-                    if (saddle != null && (((!)saddle).status == "offline"
-                            || ((!)saddle).status == "recovering")) {
+                    if (saddle != null && ((!)saddle).status == "offline") {
                         ids.add(task.id.to_string());
                     }
                 }
@@ -1301,7 +1283,6 @@ namespace ClankerSaddle.Services {
             yield pulse.bump(task_id, "task suspended");
         }
 
-        /**
         /** Withdraws the suspension stamp after a successful resume. */
         public async void clear_suspension(int64 task_id) throws Error {
             var task = yield db.query<TaskEntity>()

+ 0 - 3
src/entrypoints/TaskDetailEntrypoint.vala

@@ -110,7 +110,6 @@ namespace ClankerSaddle {
         public int64 priority { get; set; default = 5; }
         public string working_branch { get; set; default = ""; }
         public string summary { get; set; default = ""; }
-        public string plan { get; set; default = ""; }
         public string task_branch { get; set; default = ""; }
         public string branch_from { get; set; default = ""; }
         public bool review_pending { get; set; }
@@ -118,8 +117,6 @@ namespace ClankerSaddle {
         public string review_diff_url { get; set; default = ""; }
         public bool resume_available { get; set; }
         public string saddle_health { get; set; default = ""; }
-        public bool auto_approve { get; set; }
-        public Statum.Model.ActionDto? toggle_auto_approve { get; set; }
         public string display { get; set; default = ""; }
         public bool terminal { get; set; }
         public bool failed { get; set; }

+ 0 - 6
src/entrypoints/TasksEntrypoint.vala

@@ -73,12 +73,6 @@ namespace ClankerSaddle {
         public string status { get; set; default = ""; }
     }
 
-    /**
-     * Entrypoint for /tasks: the filterable, sortable queue. Filters come
-     * from the `status` and `project_id` query parameters; rows carry a
-     * dependency summary (each dependency's id and status) and whether the
-     * task is dispatch-ready.
-     */
     /**
      * The queue page's state builder, shared by the entrypoint and the
      * sealed refresh action (live pulse rehydration + the client-side

+ 0 - 5
src/pages/main.html

@@ -108,11 +108,6 @@
                     }
                 }
 
-                function hideQuoteUi() {
-                    if (quoteButton) { quoteButton.remove(); quoteButton = null; }
-                    if (quotePopover) { quotePopover.remove(); quotePopover = null; }
-                }
-
                 function hideQuoteUi() {
                     if (quoteButton) { quoteButton.remove(); quoteButton = null; }
                     if (quotePopover) { quotePopover.remove(); quotePopover = null; }