KeiSeiKit-1.0/_primitives/_rust/kei-task/atoms/add-dependency.md
Parfii-bot ae82bc6242 feat(stream-b): kei-task pilot — 3 atoms (create/search/add-dependency)
Pilot refactor per locked substrate schema. kei-task migrated to atom
layout:

- atoms/<verb>.md — YAML frontmatter + human body for 3 verbs
- atoms/schemas/<verb>-{input,output}.json — JSON Schema draft-07
- src/atoms/<verb>.rs — typed Input/Output/Error + pub fn run()
- src/atoms/mod.rs — module registry
- Cargo.toml [package.metadata.keisei] — crate-level substrate data
- src/main.rs — dispatcher for 3 pilot commands via atoms::

Zero behaviour change: 7/7 integration tests pass before and after
(create_and_get, update_persists, cycle_detected, milestone_linking,
dependency_chain_traversal, task_graph_edges, search_finds_task).

main.rs still has 5 non-migrated subcommands (update, graph,
dependency-chain, milestone, link-milestone) — scope discipline, they
migrate in later passes. main.rs 120 → 132 LOC.

Stream B pilot reference — other crates follow this pattern in v0.24+.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 00:09:55 +08:00

2 KiB

atom kind version input output errors side_effects idempotent timeout_ms deprecated stability keywords related
kei-task::add-dependency command 0.1.0
schema required example
schemas/add-dependency-input.json
from
to
from to dep_type
42 17 blocks
schema example
schemas/add-dependency-output.json
ok
true
code http_analog description
SelfDependency 400 A task cannot depend on itself
code http_analog description
InvalidDepType 400 dep_type must be one of: blocks, feeds_into, subtask_of, milestone_of, assigned_to, depends_on
code http_analog description
CycleDetected 409 The new edge would close a cycle in the task DAG
code http_analog description
StoreError 500 Underlying SQLite store failed to insert the dependency row
op domain
write kei-task-db
false 5000 null stable
task
dependency
dag
blocks
graph
kei-task::create

kei-task::add-dependency

Inserts a typed edge from -> to in the task DAG, rejecting cycles and self-loops at write time. Edge is stored idempotently via INSERT OR IGNORE — re-adding the same triple is a no-op.

Example

kei-task add-dependency 42 17 --dep-type blocks

Stdout:

dep: 42 -> 17 (blocks)

Programmatic callers receive:

{ "ok": true }

Gotchas

  • dep_type defaults to "blocks". Empty string is also treated as "blocks" for CLI convenience.
  • Cycle check is transitive — the implementation walks the existing DAG from to and refuses if it can reach from.
  • Both task ids must already exist; missing ids do NOT surface a dedicated error code in the current impl and bubble up as StoreError via foreign-key violation.
  • Re-adding an existing edge is silently idempotent (INSERT OR IGNORE) even though the atom declares idempotent: false — that flag reflects the CONTRACT (callers should not rely on retry semantics), not the specific SQL behaviour.