Forráskód Böngészése

r1: one block-kind vocabulary — the GOAL_BLOCK_* duplicates die; every raise/adopt/render/narrative path (GoalService, SaddleService's ensure_block + rfc fallback, GoalDetailEntrypoint, GoalActions, PushService) reads the single BLOCK_QUESTION/RFC/REVIEW/PLAN/COMPLETION set from TaskService, including the raw 'review'/'completion' literals the completion-review detection leaned on.

clanker 1 hónapja
szülő
commit
12de25e747

+ 17 - 26
src/Services/GoalService.vala

@@ -19,26 +19,17 @@ namespace ClankerSaddle.Services {
     public const string GOAL_FAILED = "failed";
     public const string GOAL_CANCELLED = "cancelled";
 
-    /**
-     * Valid goal block types (plan 15 C1: the values of the goal-run
-     * task's `task_blocks.type` rows — question, rfc, plan and the
-     * completion review).
-     */
-    public const string GOAL_BLOCK_QUESTION = "question";
-    public const string GOAL_BLOCK_RFC = "rfc";
-    public const string GOAL_BLOCK_PLAN = "plan";
-    public const string GOAL_BLOCK_COMPLETION = "completion";
-
     /**
      * Whether a run-task block row is THE completion review. The review is
      * raised from two paths — the web's completion raise (kind
-     * {@link GOAL_BLOCK_COMPLETION}) and the daemon's done-park (kind
-     * "review") — which adopt each other so only one row ever exists;
-     * every completion-verdict/narrative surface matches both kinds.
+     * {@link BLOCK_COMPLETION}) and the daemon's done-park (kind
+     * {@link BLOCK_REVIEW}) — which adopt each other so only one row
+     * ever exists; every completion-verdict/narrative surface matches
+     * both kinds.
      */
     private static bool is_completion_row(TaskBlock block) {
-        return block.block_type == GOAL_BLOCK_COMPLETION
-            || block.block_type == "review";
+        return block.block_type == BLOCK_COMPLETION
+            || block.block_type == BLOCK_REVIEW;
     }
 
     /** Task kinds (the `tasks.kind` wire values). */
@@ -390,12 +381,12 @@ namespace ClankerSaddle.Services {
             // only appears once the previous one was answered
             // (rejected → the agent revises).
             TaskBlock? raised = yield raise_run_block(((!)goal), "Plan submitted for review",
-                GOAL_BLOCK_PLAN, null, markdown, true);
+                BLOCK_PLAN, null, markdown, true);
             if (raised == null || ((!)raised).answer != null) {
                 // No pending submission: a fresh revision supersedes
                 // the answered history.
                 raised = yield raise_run_block(((!)goal), "Plan submitted for review",
-                    GOAL_BLOCK_PLAN, null, markdown, false);
+                    BLOCK_PLAN, null, markdown, false);
             }
             if (raised == null) {
                 return null;
@@ -415,7 +406,7 @@ namespace ClankerSaddle.Services {
                 string block_type, string[]? options = null, string? body = null) throws Error {
             var goal = yield require_goal(goal_id);
             TaskBlock? raised = yield raise_run_block(((!)goal), question,
-                block_type.length > 0 ? block_type : GOAL_BLOCK_QUESTION,
+                block_type.length > 0 ? block_type : BLOCK_QUESTION,
                 options, body, false);
             if (raised == null) {
                 return null;
@@ -449,7 +440,7 @@ namespace ClankerSaddle.Services {
             // done-park "review" block IS this review) — one row,
             // whichever path landed first.
             TaskBlock? raised = yield raise_run_block(((!)goal), "Goal completion report",
-                GOAL_BLOCK_COMPLETION, null, report, true);
+                BLOCK_COMPLETION, null, report, true);
             if (raised == null) {
                 return null;
             }
@@ -552,7 +543,7 @@ namespace ClankerSaddle.Services {
             // unanswered row past the pulse is exactly the stale-pile
             // shape plan 14 B3 defended against with mirror sweeps.
             // With one row there is nothing left to sweep.
-            if (((!)block).block_type == GOAL_BLOCK_PLAN) {
+            if (((!)block).block_type == BLOCK_PLAN) {
                 if (answer == NOTICE_PLAN_APPROVED) {
                     if (((!)block).body != null && ((!)block).body.length > 0) {
                         ((!)goal).plan = ((!)block).body;
@@ -646,12 +637,12 @@ namespace ClankerSaddle.Services {
             // done-park "review" kind, different question strings) — an
             // unanswered row of EITHER kind IS the pending review; adopt
             // it rather than raising a twin.
-            bool review_family = block_type == GOAL_BLOCK_COMPLETION
-                || block_type == "review";
+            bool review_family = block_type == BLOCK_COMPLETION
+                || block_type == BLOCK_REVIEW;
             foreach (var existing in yield tasks.list_blocks(((!)run).id)) {
                 if (review_family && existing.answer == null
-                        && (existing.block_type == GOAL_BLOCK_COMPLETION
-                            || existing.block_type == "review")) {
+                        && (existing.block_type == BLOCK_COMPLETION
+                            || existing.block_type == BLOCK_REVIEW)) {
                     return existing;
                 }
                 bool same = dedupe_on_type
@@ -800,7 +791,7 @@ namespace ClankerSaddle.Services {
             if (run != null) {
                 foreach (var block in yield tasks.list_blocks(((!)run).id)) {
                     if (block.created_at != null) {
-                        if (block.block_type == GOAL_BLOCK_PLAN) {
+                        if (block.block_type == BLOCK_PLAN) {
                             rows.add(new NarrativeRow() {
                                 kind = "plan-submitted", at = block.created_at,
                                 text = @"Plan revision #$(block.id) submitted for review" });
@@ -815,7 +806,7 @@ namespace ClankerSaddle.Services {
                         }
                     }
                     if (block.answered_at != null) {
-                        if (block.block_type == GOAL_BLOCK_PLAN) {
+                        if (block.block_type == BLOCK_PLAN) {
                             bool approved = block.answer == NOTICE_PLAN_APPROVED;
                             rows.add(new NarrativeRow() {
                                 kind = approved ? "plan-approved" : "plan-rejected",

+ 1 - 1
src/Services/PushService.vala

@@ -275,7 +275,7 @@ namespace ClankerSaddle.Services {
         public static PushNotification goal_block_notification(string goal_title,
                 int64 goal_id, string block_type, string question) {
             string label = block_kind_label(block_type);
-            if (block_type == GOAL_BLOCK_COMPLETION) {
+            if (block_type == BLOCK_COMPLETION) {
                 label = "completion review";
             }
             return new PushNotification() {

+ 4 - 4
src/Services/SaddleService.vala

@@ -1381,9 +1381,9 @@ namespace ClankerSaddle.Services {
                     // daemon's done park and the web's completion raise
                     // are the SAME review raised from two paths — one
                     // row, whichever landed first.
-                    if ((incoming_type == "review" || incoming_type == "completion")
-                            && (existing.block_type == "review"
-                                || existing.block_type == "completion")) {
+                    if ((incoming_type == BLOCK_REVIEW || incoming_type == BLOCK_COMPLETION)
+                            && (existing.block_type == BLOCK_REVIEW
+                                || existing.block_type == BLOCK_COMPLETION)) {
                         return;
                     }
                 }
@@ -1419,7 +1419,7 @@ namespace ClankerSaddle.Services {
             if (question.length > 0) {
                 return question;
             }
-            return block_string_or(block, "type", "block_type") == "rfc"
+            return block_string_or(block, "type", "block_type") == BLOCK_RFC
                 ? "Request for comments" : "";
         }
 

+ 1 - 1
src/actions/GoalActions.vala

@@ -382,7 +382,7 @@ namespace ClankerSaddle {
                     && (verdict.length > 0 || feedback.strip().length > 0)) {
                 var block = yield goals.get_block(block_id);
                 bool plan_kind = block != null
-                    && ((!)block).block_type == GOAL_BLOCK_PLAN;
+                    && ((!)block).block_type == BLOCK_PLAN;
                 if (verdict == "accept") {
                     answer = plan_kind
                         ? NOTICE_PLAN_APPROVED : NOTICE_REVIEW_APPROVED;

+ 5 - 5
src/entrypoints/GoalDetailEntrypoint.vala

@@ -28,7 +28,7 @@ namespace ClankerSaddle {
     public class GoalBlockView : Object {
         public int64 id { get; set; }
         public string question { get; set; default = ""; }
-        public string block_type { get; set; default = "question"; }
+        public string block_type { get; set; default = BLOCK_QUESTION; }
         public string[] options { get; set; default = {}; }
         public string body { get; set; default = ""; }
         public bool answered { get; set; default = false; }
@@ -253,7 +253,7 @@ namespace ClankerSaddle {
                     if (block.is_completion_review && completion_pending == null) {
                         completion_pending = block;
                     }
-                    if (block.block_type == GOAL_BLOCK_PLAN) {
+                    if (block.block_type == BLOCK_PLAN) {
                         plan_revisions.add(block);
                     }
                 }
@@ -427,14 +427,14 @@ namespace ClankerSaddle {
             // Plan 15 C1: the goal's blocks ARE the goal-run task's
             // blocks — one row per question, answered in place.
             foreach (var block in yield goals.list_blocks(goal.id)) {
-                bool pending_plan = block.block_type == GOAL_BLOCK_PLAN
+                bool pending_plan = block.block_type == BLOCK_PLAN
                     && block.answer == null;
                 // The completion review may ride either kind: the web's
                 // completion raise or the daemon's done-park review block
                 // (adopted — one row, whichever landed first).
                 bool pending_completion = block.answer == null
-                    && (block.block_type == GOAL_BLOCK_COMPLETION
-                        || block.block_type == "review");
+                    && (block.block_type == BLOCK_COMPLETION
+                        || block.block_type == BLOCK_REVIEW);
                 var view = new GoalBlockView() {
                     id = block.id,
                     question = block.question,