# Atlas Brief — Kade Tasks Table

**From:** Larry
**To:** Atlas
**Date:** 2026-05-21
**Workspace:** Operate from `Team Inbox/` per `feedback_atlas_workspace.md`.

---

## Context

Kade is the new Personal Ops Assistant agent (replaced Qordinate). He lives in Slack DMs and writes to the Atlas DB. His persona/voice/rules are already filed at `Team/Kade/profile.md` — read that first to understand who he is.

For the build context, see the master spec: `Team Inbox/2026-05-21 - Larry - Kade Build Master Spec.md`.

Riv is building the Slack bridge + scheduler + Qordinate API export in parallel. Your schema is the contract Riv writes against — lock it down first, share it with Riv, then build the rest.

---

## Goal

Build the `tasks` table in the PKA internal DB, linked to the existing `projects` table (activated 2026-05-18). Provide UI views that Kade and Jimmie can use.

---

## Schema Requirements

### `tasks` table

| Column | Type | Notes |
|---|---|---|
| `id` | UUID/serial PK | |
| `title` | text NOT NULL | the task itself |
| `notes` | text | optional context/details |
| `due_date` | timestamp | nullable for no-due-date items |
| `completed_at` | timestamp | nullable; set when status flips to done |
| `status` | enum(`open`, `done`, `snoozed`, `dropped`) | default `open` |
| `priority` | int | 1=urgent, 2=normal, 3=someday; default 2 |
| `project_id` | FK → projects.id | nullable; null = no project link |
| `recurring_rule` | JSON | optional; cron-ish format for repeat patterns |
| `source` | enum(`qordinate-import`, `slack-text`, `slack-voice`, `slack-slash`, `manual`, `kade-inferred`) | provenance tracking |
| `original_input` | text | the raw user input that created this task (for "all I've got saved is..." lookups) |
| `dnd_critical` | boolean | default false; true = bypass DND windows (meds, deadlines) |
| `created_at` | timestamp | |
| `updated_at` | timestamp | |

**Indexes:**
- `due_date` (for scheduler scans)
- `project_id` (for project rollups)
- `status` (for "open tasks" filters)
- composite: `(status, due_date)` for "today's open tasks" queries

### Junction needed?

No junction table — single FK from `tasks` to `projects` is sufficient. A task either belongs to one project or none.

### Recurring rule format

Suggest a simple JSON shape:
```json
{
  "freq": "daily" | "weekly" | "monthly" | "custom",
  "interval": 1,
  "byday": ["mon", "tue", "wed", "thu", "fri"],
  "time": "07:00",
  "timezone": "America/Chicago",
  "start_date": "2026-05-22",
  "end_date": null
}
```

Riv will write to this; you don't need to interpret it (the scheduler does).

---

## UI Requirements

Three primary views — match the patterns Kade uses in Slack:

### 1. Project Rollup View
- For each project: count of open tasks, count completed this week, next due date
- Click a project → see all its tasks (open + completed history)

### 2. "Today" View
- Default cap: 8 items, configurable
- Show priority items first, then due-today, then overdue
- "List From Hell" toggle to show full backlog (hidden by default — this is a hard rule, not a preference)

### 3. Task Detail / Edit
- Edit any field
- Show source ("captured via Slack voice memo at 8:47 AM")
- Show original input verbatim
- Project link with create-new option

---

## API Contract for Riv

Riv needs at minimum:
- `POST /tasks` — create
- `PATCH /tasks/:id` — update any field (status, due_date, project_id, etc.)
- `POST /tasks/bulk-complete` — array of task IDs → mark done in one call (for "X, Y, Z done")
- `GET /tasks?status=open&due_before=...` — for scheduler scans
- `GET /tasks?project_id=...` — for project rollups
- `POST /projects` — create new project inline (when Kade infers a project that doesn't exist)
- `GET /projects?match=...` — fuzzy lookup by name (Kade needs to find Acadian when input is "acadian")

Lock the API shape in your first hour and post it as a follow-up file:
`Team Inbox/2026-05-22 - Atlas to Riv - Tasks API Contract.md`

---

## Acceptance Criteria

- Schema migrated, indexes in place
- API endpoints functional and documented
- UI views working (Project Rollup, Today, Task Detail)
- Sample data flows end-to-end (manual task create → appears in Today view → mark done → moves to history)
- Coordinated with Riv on contract

---

## Status Updates

File status updates as:
`Team Inbox/2026-05-XX - Atlas to Larry - Kade Tasks Table Status.md`

Flag blockers immediately. Per `feedback_jimmie_ship_speed_preference.md`, bias toward shipping; Larry/Jimmie can review supervision cost as you go.

Kickoff: next session.

— Larry
