feat(layout): topological row assignment from task dependencies - #17
Merged
Conversation
Replace sequential row=i layout with Kahn topological ordering so blockers render above blocked tasks. Deterministic tie-break uses input array order; cycles and unknown dependency IDs are handled safely. Assisted-by: Cursor <cursor@cursor.com> Co-authored-by: Cursor <cursoragent@cursor.com> Assisted-by: multi-agent-shogun-aki-tweak
|
Important Testing in progress…🟢 UI Tests: 5 tests unchanged |
|
Tip All tests passed and all changes approved!🟢 UI Tests: 5 tests unchanged |
assign_rows now returns one entry per input task (fixing bar/arrow zip mismatch in build.rs) and uses Tarjan SCC condensation so downstream tasks stay below cycle blockers. Add integration tests for reversed input and cycle+downstream graphs. Assisted-by: Cursor <cursor@cursor.com> Assisted-by: multi-agent-shogun-aki-tweak
Replace SCC-level priority topological sort with DFS clustering so dependents emit immediately after all blockers (acceptance: [t1,t3,t2]→rows [0,2,1]). Assisted-by: multi-agent-shogun-aki-tweak
Replace linear Vec::find id resolution with HashMap for O(V+E) edge construction. Replace recursive try_emit_dependent_sccs with an explicit stack that preserves byte-identical clustering order. Add regression tests for 10k chains and 5000_dense timing. Co-authored-by: Cursor <cursoragent@cursor.com> Assisted-by: multi-agent-shogun-aki-tweak
Replace O(V²) predecessor scans in drain_dependent_sccs with remaining_indegree decrements on emit. Add join fixture (2k blockers → sink) guarding linear-time fan-in. Output order unchanged. Co-authored-by: Cursor <cursoragent@cursor.com> Assisted-by: multi-agent-shogun-aki-tweak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
SPEC の P2 未実装項目「依存関係を考慮したトポロジカル行割り当て」を Rust core に実装する。
これまで
layout::assign_rowsはタスク配列の順序をそのまま行番号にしていた(row = i)ため、GanttDepを無視しており、blocker(先行タスク)が blocked(後続)より下に来ることがあった。本 PR で依存トポロジ順(blocker を上、blocked を下)に並べ替える。変更内容
crates/koyori-arc-core/src/layout.rs—assign_rowsを deps 考慮のトポロジカル順序へ。Kahn 法でソートし、blocker_task_id(先行)を小さい row(上)へ割り当てる。呼び出し側が deps を渡せるようシグネチャを更新。crates/koyori-arc-core/src/display_list/build.rs— 呼び出し元を新シグネチャに追随。設計上の不変条件
HashMap走査順を出力順に混入させない)。SVG が byte 不変である前提(golden fixture / DOM 仮想化)を壊さない。task_relationsは循環しうる。panic / 無限ループを起こさず、循環ノードは Kahn 処理後に入力順で決定的に割り当て、全タスクを必ず 1 行ずつ配置する(欠落・重複なし)。tasksに存在しない id を参照する dep は無視する。スコープ
本 PR は「1 タスク = 1 行のトポロジ順序」に限定する。時間ベースの行パッキング(時間的に重ならないタスクを同一行に詰める)は SPEC の将来課題として温存する。
テスト
layout.rsに variant 網羅の回帰テストを追加(deps 無し = 入力順維持 / 単純 blocker→blocked / 鎖 A→B→C / ダイヤモンド / 非連結タスクの安定順序 / 循環 = panic せず決定的 / 未知 id dep 無視 / 空入力 / 決定性)。cargo nextest run: 72 passedwasm-pack test --node: 13 passed※ DRAFT 解除・merge は maintainer 判断。
Assisted-by: multi-agent-shogun-aki-tweak