KeiSeiKit-1.0/_primitives/_rust/kei-task/atoms/create.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

73 lines
1.9 KiB
Markdown

---
atom: kei-task::create
kind: command
version: "0.1.0"
input:
schema: schemas/create-input.json
required: [title]
example: { title: "Fix auth bug", priority: "high" }
output:
schema: schemas/create-output.json
example: { id: 42, created_at: 1714000000 }
errors:
- code: InvalidPriority
http_analog: 400
description: "Priority must be one of: critical, high, medium, low"
- code: InvalidTitle
http_analog: 400
description: "Title must be non-empty"
- code: StoreError
http_analog: 500
description: "Underlying SQLite store failed to insert the task"
side_effects:
- { op: write, domain: kei-task-db }
idempotent: false
timeout_ms: 5000
deprecated: null
stability: stable
keywords: [task, todo, create, dag, planning]
related:
- "[[kei-task::add-dependency]]"
- "[[kei-task::search]]"
---
# kei-task::create
Creates a new task row in the kei-task SQLite DAG. Returns the inserted
row id and the `created_at` unix timestamp. Also indexes title +
description into the FTS table used by `kei-task::search`.
## Example
kei-task create "Fix auth bug" --priority high --description "Token rotation fails on leap second"
Returns the new task id on stdout:
42
Programmatic callers (runtime invocation) receive:
{ "id": 42, "created_at": 1714000000 }
## Gotchas
- `priority` defaults to `"medium"` if omitted. Case sensitive —
`High` returns `InvalidPriority`.
- `description` defaults to empty string; blank descriptions are still
indexed by FTS but yield no search hits until populated.
- `milestone_id` in the input schema is reserved for future use; the
current CLI does NOT accept it — link via `kei-task link-milestone`
after creation.
- Title uniqueness is NOT enforced at DB level; duplicate titles are
allowed and will all be returned by `kei-task::search`.
## Related
- [[kei-task::add-dependency]] — wire the new task into the DAG
- [[kei-task::search]] — look up by title / description