Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var PrioritizeCmd = &cobra.Command{ Use: "prioritize <REQ-ID> <feature> <priority>", Short: "Update priority of a CANARY token", Long: `Update the priority of a specific token (1=highest, 10=lowest). Priority affects ordering in list and search results.`, Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { prompt, _ := cmd.Flags().GetString("prompt") if prompt != "" { if _, err := utils.LoadPrompt(prompt); err != nil { return err } } dbPath, _ := cmd.Flags().GetString("db") root, _ := cmd.Flags().GetString("root") if root == "" { root = "." } if !cmd.Flags().Changed("db") { dbPath = filepath.Join(root, ".canary", "canary.db") } else if !filepath.IsAbs(dbPath) { dbPath = filepath.Join(root, dbPath) } reqID := args[0] feature := args[1] priority, err := strconv.Atoi(args[2]) if err != nil { return fmt.Errorf("invalid priority: %s (must be 1-10)", args[2]) } if priority < 1 || priority > 10 { return fmt.Errorf("priority must be between 1 (highest) and 10 (lowest)") } projectID, err := utils.WriteProjectID(cmd, root) if err != nil { return err } db, err := storage.OpenRW(dbPath) if err != nil { return fmt.Errorf("open database: %w", err) } defer func() { _ = db.Close() }() allTokens, err := db.GetTokensByReqID(projectID, reqID) if err != nil { return utils.GuardContract(cmd, err) } var matched []*storage.Token for _, t := range allTokens { if t.Feature == feature { matched = append(matched, t) } } if len(matched) == 0 { return fmt.Errorf("no token found for %s/%s", reqID, feature) } ops := make([]canaryscan.RewriteOp, 0, len(matched)) for _, t := range matched { ops = append(ops, canaryscan.RewriteOp{ FilePath: t.FilePath, LineNumber: t.LineNumber, Identity: map[string]string{"REQ": reqID}, Set: map[string]string{"PRIORITY": strconv.Itoa(priority)}, }) } restore, err := canaryscan.RewriteTokensAtomic(root, ops) if err != nil { return fmt.Errorf("update source token: %w", err) } if err := db.UpdatePriority(projectID, reqID, feature, priority); err != nil { if rerr := restore(); rerr != nil { return fmt.Errorf("update priority: %w (source restore also failed: %v)", err, rerr) } return fmt.Errorf("update priority: %w (source change rolled back)", err) } fmt.Printf("✅ Updated priority for %s/%s to %d\n", reqID, feature, priority) return nil }, }
CANARY: REQ=ENG-4310; FEATURE="PrioritizeCmd"; ASPECT=CLI; STATUS=TESTED; OWNER=canary; TEST=TestAuditR07MutationsSurviveReindex,TestPrioritizePartialFailureLeavesSourceUntouched,TestPrioritizeRespectsRoot,TestPrioritizeDBFailureRestoresSource; UPDATED=2026-08-31
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.