# Cadence — Background Task Queue

This is the heartbeat of background work. A queue of natural-language
tasks processed by the `cadence-executor` subconscious partition.

## How It Works

1. Anyone drops a `.pending` file into `inbox/`
2. Every cadence tick (~5 min), inbox merges into `queue.md`
3. The `cadence-executor` partition reads `queue.md`, does the work, checks items off

## How to Queue a Task

Write a `.pending` file to `inbox/`. One line per file.

**File name**: `<ISO-timestamp>_<label>.pending`
**Content**: a single line — either bare text or a checkbox item.

```
- [ ] (cadence:fast) describe the task here
```

The merge will auto-wrap bare text into `- [ ]` if needed.

### Priority Tags (optional)

- `(cadence:fast)` — process first
- `(cadence:slow)` — batch when idle
- `(cadence:cron@hourly)` — periodic maintenance

### Example: Trigger a Job Immediately

To make the job scheduler pick up a job on its next 60-second scan,
queue a state reset:

```
- [ ] (cadence:fast) trigger job:<job-id> — reset last_scheduled_at in its .state.json so the scheduler treats it as due
```

The cadence-executor will read the job's `.state.json` sidecar
(in `~/.aladuo/var/jobs/active/<job-id>.state.json`), set `last_scheduled_at`
to null, and the job scheduler spawns it within 60 seconds.

### Example: Memory Compression

```
- [ ] [memory:claude-compress] Compress CLAUDE.md
```

## Reading Queue Status

`queue.md` shows all items. `- [ ]` = pending, `- [x]` = done.
The `## Notes` section has timestamped execution history.

## Concurrency Safety

`queue.md` has exactly one writer: the cadence process.
Everyone else writes to `inbox/` — that's the safe entry point.
