@@ -299,7 +299,188 @@ mysql -u claude_user -p claude_knowledge -e "SELECT * FROM tickets ORDER BY id D
299299
300300---
301301
302- ## Current Features (v2.33.0)
302+ ## Ticket Execution Logic (v2.80.11+)
303+
304+ ### Execution Order
305+
306+ Tickets are selected for execution based on:
307+ 1 . ** Status:** Must be ` open ` , ` new ` , or ` pending `
308+ 2 . ** Parent:** If has ` parent_ticket_id ` , parent must be ` done ` or ` skipped `
309+ 3 . ** Dependencies:** ALL dependencies must be ` done ` or ` skipped `
310+ 4 . ** Sequence Order:** Lower ` sequence_order ` runs first
311+ 5 . ** Parallel:** Tickets with ** same sequence_order** run in parallel (max 5)
312+ 6 . ** Forced Queue:** ` is_forced=1 ` tickets get priority
313+
314+ ### Parallel Execution
315+
316+ ** Two levels of parallelism:**
317+
318+ | Level | Max Parallel | Scope |
319+ | -------| --------------| -------|
320+ | Projects | 10 | Different projects run simultaneously |
321+ | Tickets | 5 | Same ` sequence_order ` within a project |
322+
323+ ** Per Project - Tickets with same ` sequence_order ` :**
324+ ```
325+ Project A:
326+ sequence_order=1: [Ticket 1, 2, 3] → run in parallel (max 5)
327+ sequence_order=2: [Ticket 4] → waits for 1,2,3 to finish
328+ sequence_order=3: [Ticket 5, 6] → run in parallel after 4
329+
330+ Project B: (runs simultaneously with Project A)
331+ sequence_order=1: [Ticket 7]
332+ sequence_order=2: [Ticket 8, 9]
333+ ```
334+
335+ ** Note:** ` sequence_order ` is ** per project** , not global.
336+
337+ ** Use cases:**
338+ - Independent setup tasks (install deps, create folders)
339+ - Multiple tests that don't conflict
340+ - Parallel feature development in different files
341+
342+ ### Key Concepts
343+
344+ | Concept | Purpose | Blocks Execution? |
345+ | ---------| ---------| -------------------|
346+ | ` sequence_order ` | Order + parallel grouping | NO - same seq runs parallel |
347+ | ` parent_ticket_id ` | Context + implicit dependency | ** YES** - parent must be done |
348+ | ` depends_on ` (ticket_dependencies) | Explicit dependency | ** YES** - must be done/skipped |
349+ | ` deps_include_awaiting ` | Controls auto-review behavior | NO - affects review only |
350+
351+ ### Parent Tickets (parent_ticket_id)
352+
353+ ** BLOCKS execution.** Child ticket waits for parent to be ` done ` or ` skipped ` .
354+
355+ - Parent is an ** implicit dependency** - no need to add explicit dependency
356+ - Child inherits context from ALL ancestors (recursive)
357+ - Child's summary includes ancestor summaries
358+
359+ ``` sql
360+ -- Sub-ticket that waits for parent (automatic)
361+ INSERT INTO tickets (parent_ticket_id, ...) VALUES (1 , ...);
362+ -- Child will NOT run until parent (ticket 1) is 'done' or 'skipped'
363+
364+ -- Sub-ticket with additional dependencies
365+ INSERT INTO tickets (parent_ticket_id, ...) VALUES (1 , ...);
366+ INSERT INTO ticket_dependencies (ticket_id, depends_on_ticket_id) VALUES (child_id, other_ticket_id);
367+ -- Child waits for BOTH parent AND other_ticket
368+ ```
369+
370+ ### Dependencies (ticket_dependencies table)
371+
372+ ** Explicit dependencies** for tickets that need to wait for non-parent tickets.
373+
374+ ``` sql
375+ -- Ticket 2 depends on Ticket 1 (not a parent-child relationship)
376+ INSERT INTO ticket_dependencies (ticket_id, depends_on_ticket_id) VALUES (2 , 1 );
377+ ```
378+
379+ ### deps_include_awaiting (Relaxed vs Strict Mode)
380+
381+ ** Does NOT affect execution order.** Only affects auto-review behavior.
382+
383+ | Value | Mode | Auto-Review Behavior |
384+ | -------| ------| ---------------------|
385+ | ` 0 ` | Strict | Waits for user to close ` awaiting_input ` tickets |
386+ | ` 1 ` | Relaxed | Auto-closes ` awaiting_input ` tickets after delay |
387+
388+ ### Auto-Review System
389+
390+ When a ticket completes (` completed ` result), it goes to ` awaiting_input ` status.
391+
392+ ** In Relaxed Mode (deps_include_awaiting=1):**
393+ 1 . Haiku classifies the result (COMPLETED/QUESTION/ERROR)
394+ 2 . If "COMPLETED" → auto-closes to ` done `
395+ 3 . If "QUESTION/ERROR" → stays ` awaiting_input `
396+ 4 . Delay: ` AUTO_REVIEW_DELAY_SECONDS ` (default: 10 seconds)
397+ 5 . Summary NOT generated here (lazy generation when child starts)
398+
399+ ** In Strict Mode (deps_include_awaiting=0):**
400+ - No auto-review
401+ - User must manually close tickets
402+
403+ ** Manual Close (from web):**
404+ - Just closes the ticket (no summary generation)
405+
406+ ### Summary Generation (Lazy - On Demand)
407+
408+ Summaries are generated ** only when needed** - when a child ticket starts:
409+
410+ 1 . Child ticket starts → checks if ancestors have ` result_summary `
411+ 2 . If ancestor has NO summary → Haiku generates it from last 50 messages
412+ 3 . Summary saved to ancestor's ` result_summary `
413+ 4 . Child receives context with all ancestor summaries
414+
415+ ** Haiku Summary Settings:**
416+ - Last 50 messages from conversation
417+ - Each message truncated to 500 chars
418+ - Total context max 15,000 chars
419+ - Output summary max 500 chars
420+
421+ ** Context format for child:**
422+ ```
423+ === PARENT TICKET CONTEXT (2 levels) ===
424+ [Root] PROJ-0001 - Setup database
425+ Description: Create MySQL schema...
426+ Result: Created users, products, orders tables with indexes...
427+
428+ [Level 1] PROJ-0002 - Build auth
429+ Description: Implement authentication...
430+ Result: JWT auth with login/logout, password reset via email...
431+
432+ This is a sub-task. Use the parent context to understand the overall goal.
433+ ==================================================
434+ ```
435+
436+ - Summary stored in ` result_summary ` field (max 2000 chars)
437+ - Only generated once per ticket (cached)
438+ - Tickets without children never generate summary (saves Haiku calls)
439+
440+ ### Execution Flow Example
441+
442+ ```
443+ Project with deps_include_awaiting=1 (relaxed):
444+
445+ Ticket 1 (seq=1): Setup → runs first
446+ Ticket 2 (seq=2): depends on 1 → waits for 1 to be 'done'
447+ Ticket 3 (seq=3): no deps → can run after 1 finishes
448+
449+ With sub-tickets (parent = implicit dependency):
450+ Parent (seq=1): Main task → runs first
451+ Child (seq=2, parent_ticket_id=Parent):
452+ → waits for parent to be 'done' (automatic)
453+ → gets parent's context and summary
454+ ```
455+
456+ ### SQL Query (get_next_ticket)
457+
458+ ``` sql
459+ SELECT * FROM tickets t
460+ WHERE t .project_id = ? AND t .status IN (' open' , ' new' , ' pending' )
461+ AND NOT EXISTS (
462+ -- Skip if has unfinished dependencies
463+ SELECT 1 FROM ticket_dependencies td
464+ JOIN tickets dt ON dt .id = td .depends_on_ticket_id
465+ WHERE td .ticket_id = t .id
466+ AND dt .status NOT IN (' done' , ' skipped' )
467+ )
468+ AND (
469+ -- Parent must be done/skipped (implicit dependency)
470+ t .parent_ticket_id IS NULL
471+ OR EXISTS (
472+ SELECT 1 FROM tickets pt
473+ WHERE pt .id = t .parent_ticket_id
474+ AND pt .status IN (' done' , ' skipped' )
475+ )
476+ )
477+ ORDER BY t .is_forced DESC , t .sequence_order ASC , t .id ASC
478+ LIMIT 1
479+ ```
480+
481+ ---
482+
483+ ## Current Features (v2.80.11)
303484
304485- Project & Ticket Management
305486- Real-time Chat with Claude
@@ -334,5 +515,5 @@ mysql -u claude_user -p claude_knowledge -e "SELECT * FROM tickets ORDER BY id D
334515
335516---
336517
337- * Last Updated: 2026-01-11 *
338- * Current Version: 2.33.0 *
518+ * Last Updated: 2026-01-22 *
519+ * Current Version: 2.80.10 *
0 commit comments