kin: KIN-DOCS-004-backend_dev

This commit is contained in:
Gros Frumos 2026-03-19 20:30:50 +02:00
parent de52526659
commit ae2f0f1c81
8 changed files with 66 additions and 12 deletions

View file

@ -165,6 +165,7 @@ CREATE TABLE IF NOT EXISTS department_handoffs (
artifacts JSON,
decisions_made JSON,
blockers JSON,
context_packet JSON DEFAULT NULL,
status TEXT DEFAULT 'pending',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
@ -703,6 +704,13 @@ def _migrate(conn: sqlite3.Connection):
""")
conn.commit()
# Add context_packet column to department_handoffs (KIN-DOCS-004)
if "department_handoffs" in existing_tables:
handoff_cols = {r[1] for r in conn.execute("PRAGMA table_info(department_handoffs)").fetchall()}
if "context_packet" not in handoff_cols:
conn.execute("ALTER TABLE department_handoffs ADD COLUMN context_packet JSON DEFAULT NULL")
conn.commit()
# Add test_command column to projects (KIN-ARCH-008); NULL = auto-detect (KIN-101)
projects_cols = {row["name"] for row in conn.execute("PRAGMA table_info(projects)")}
if "test_command" not in projects_cols:

View file

@ -42,6 +42,7 @@ _JSON_COLUMNS: frozenset[str] = frozenset({
"dependencies",
"steps",
"artifacts", "decisions_made", "blockers",
"context_packet",
"extra_json",
"pending_actions",
})
@ -1191,14 +1192,16 @@ def create_handoff(
decisions_made: list | None = None,
blockers: list | None = None,
status: str = "pending",
context_packet: dict | list | None = None,
) -> dict:
"""Record a department handoff with artifacts for inter-department context."""
cur = conn.execute(
"""INSERT INTO department_handoffs
(pipeline_id, task_id, from_department, to_department, artifacts, decisions_made, blockers, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
(pipeline_id, task_id, from_department, to_department, artifacts, decisions_made, blockers, context_packet, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
(pipeline_id, task_id, from_department, to_department,
_json_encode(artifacts), _json_encode(decisions_made), _json_encode(blockers), status),
_json_encode(artifacts), _json_encode(decisions_made), _json_encode(blockers),
_json_encode(context_packet), status),
)
conn.commit()
row = conn.execute(