# Concepts

How Mindtape stores each task as a Typst file, reads the files on every command, and names and links tasks.

## A task is a file

Each task is one `.typ` file. The file imports the Mindtape prelude and passes the task’s fields to `task.with(...)` in a show rule. Everything below that line is the task’s body, in Typst markup. A task from `examples/api-service/`:

````typ
#import "@local/mindtape:0.4.0": *
#show: task.with(
  title: "Add a Redis client to the app state",
  kind: "feat",
  priority: ice(impact: 7, confidence: 0.8, ease: 6),
  status: proposed(2026, 9, 25),
  estimate: (src-files: 3),
  tags: ("stateless",),
)

== AS-IS
AppState holds a Postgres pool and nothing else, so no replica shares a counter.

+ Open `src/state.rs`.
+ 🔴 `AppState` holds a Postgres pool and nothing else. A handler that needs a counter shared by every replica has nowhere to keep it.

== TO-BE
- 🟢 Handlers reach a pooled Redis connection through `AppState`.

```rust
let redis = ConnectionManager::new(&config.redis_url).await?;
let state = AppState { db, redis };
```

== Changes
- `Cargo.toml`: add the `redis` crate with its `tokio-comp` and `connection-manager` features.
- `src/config.rs`: read `REDIS_URL` from the environment.
- `src/state.rs`: open a `ConnectionManager` from `REDIS_URL` at startup and keep it in `AppState`.

== Alternatives
- Counters in Postgres. Every failed login would become a write to the primary database.

== Out of scope
- Caching responses in Redis. This task only connects to it.
````

`mt` reads the task sources under the roots you list in `[[tasks.roots]]`. A root can be a backlog folder or the source tree itself, so a task can sit next to the code it changes. [Which files count as tasks](https://mlavrinenko.github.io/mindtape/concepts/index.md#which-files-count-as-tasks) says which files under a root qualify. The [Task DSL](https://mlavrinenko.github.io/mindtape/dsl/index.md) lists every field.

### Which files count as tasks

A task source is a regular `.typ` file under a configured `[[tasks.roots]]` entry, outside every reserved component and template directory below. `mt` handles a path as text: it folds `.` and `..` without touching the filesystem. A root doesn’t need a trailing slash, and whether a file is a task depends only on its resolved path. These rules narrow that base:

- The extension is `.typ`, case-sensitive, so `TASK.TYP` is not a task.
- No path component may be `.mindtape` or `.git`, in any ASCII case. The project’s metadata directory never contains a task.
- A file under a `[templates] dirs` entry is a template, not a task. A [template](https://mlavrinenko.github.io/mindtape/templates/index.md) is a `.typ` file with `slot(...)` calls, and `mt check` checks it on its own. Its `task.with` call earns no warning: a template is what its directory is for, not a task saved in the wrong place.
- A path matching a root’s `exclude` glob is not a task under that root. The globs are relative to the root, the same base `derive-tags` uses, and another root can still admit the path.
- The entry at the path must be a regular file. A symlink is never a task source, even one whose target is a regular `.typ` file. The scan doesn’t follow a directory symlink.

`mt` refuses a working-tree config when it loads the config. A config whose root is under `.mindtape` or `.git`, whose template directory contains a root or the project root, or whose `exclude` glob does not compile, could never yield a task.

In a Git work tree, `mt` asks Git which paths are in the working tree: every tracked regular file and every untracked file Git does not ignore. That keeps `mt ls` in step with the commit states. A tracked file stays a task when an ignore pattern matches it, and an untracked ignored file is not a task. A tracked file deleted from the working tree is not a task there, though a commit state still lists it. An ignored task root lists only its tracked files, and the load warns once that the root’s untracked files are invisible. Unignore the root to load them.

Git’s rules are the repository’s `.gitignore` files, `.git/info/exclude` and your global excludes file. The last two are machine-local, so two people can see different tasks in one clone.

An untracked ignored path is not scanned at all. When an ignore rule starts matching an untracked task file, that task leaves the listing. Its links resolve as missing, but the file stays where it is: `mt` does not delete it. An ignore rule doesn’t affect a tracked file.

A root outside the project is working-tree only. `mt` finds its files for `mt ls`, `mt check` and `mt fix`, and a commit state cannot list them, so commit classification reads only paths inside the project.

Outside a Git work tree, or on a machine without `git`, `mt` walks each root on disk with the same extension, reserved-name and template rules. The walk skips the ignore rules and does not follow a directory symlink. Any other Git failure stops the load with an error about the root.

Four examples.

- A project whose only root is `.` keeps its backlog across the tree. Its template at `.mindtape/templates/task.typ` sits under a reserved component and a template directory, so the template is not a task, while a real task can sit beside the code it changes.
- A tracked `tasks/old.typ` that a `.gitignore` line matches stays a task, because Git still tracks it. `git rm --cached tasks/old.typ` drops it from the listing without touching the file.
- A task file that becomes a symlink, such as `tasks/alias.typ -> ../shared/task.typ`, stops being a source even when the target is a regular `.typ` file.
- `mt add` refuses a destination that is itself a symlink.

## Every command reads the files

There’s no daemon, database or index. Each `mt` command evaluates the task files under the roots with the Typst compiler, then applies the project’s config to what they contain. So the next command sees a saved change, whether it came from your editor, a script, an agent or `mt` itself. Git versions the backlog with the code, and each branch has its own tasks.

To keep this fast, `mt` caches each file’s result in `.mindtape/cache/`, keyed by a hash of the file’s bytes, and skips a file that hasn’t changed.

## Identity

A task’s id is its filename stem, the file name without `.typ`, so `tasks/add-redis-client.typ` is `add-redis-client`. Every command that takes a task takes its id, as in `mt done add-redis-client`. Set the `id:` field to give a task a different id. `mt check` reports two tasks with the same id.

`mt ls` also shows a short hash for each task in its `SLUG#` column, like `re8`. Every command takes it in place of the name.

## Links name files

A `links:` target is the path from the linking file to the target file. A task in the same folder is `"other.typ"`, and a task one folder over is `"../api/other.typ"`. `id:` plays no part in it. `mt check` reports a target that doesn’t point at a task file, so if you rename a file by hand, every link to it breaks:

```
$ mv tasks/pick-a-provider.typ tasks/choose-a-provider.typ
$ mt check
error: tasks/wire-oauth.typ:9: depends-on: link target `tasks/pick-a-provider.typ` not found
error: 1 problem in 1 task
```

`mt mv` renames the file and rewrites each link to it. It keeps the file in its folder, because a folder can set the task’s [derived tags](https://mlavrinenko.github.io/mindtape/derived-tags/index.md):

```
$ mt mv pick-a-provider choose-a-provider
moved tasks/pick-a-provider.typ -> tasks/choose-a-provider.typ
rewrote 1 link in 1 file
$ mt check
ok: 8 tasks
```

[Task links](https://mlavrinenko.github.io/mindtape/links/index.md) covers the link kinds and `mt link`, which writes the path for you.

## Extension fields

An `x-<ns>` field, such as `x-team`, stores your own data, or data for a tool built on Mindtape, such as `x-speconaut`. `mt ls --json` passes it through unchanged under `extras`.

To have `mt` check one, declare it in `[tasks.fields.x-<ns>]`. [Configuration](https://mlavrinenko.github.io/mindtape/config/index.md#extension-fields) covers the rest.

## Mistake handling

Typst stops a file before any rule runs. A misspelled field, or any other field `task` doesn’t declare, fails with `unexpected argument: titel`. A helper refuses a value it can’t hold, like a status note that isn’t a content block.

`mt check` checks everything else against the project’s config: the [status legend](https://mlavrinenko.github.io/mindtape/statuses/index.md), the priority and difficulty scales, `kind`, required fields, links, recurrence and the type of every value. It states the field and shows where the wrong value is, such as `tags[1]`.

## Configuration

`.mindtape/config.toml` contains only what you change from the defaults built into `mt`. [Configuration](https://mlavrinenko.github.io/mindtape/config/index.md) covers which config files `mt` merges, in what order, and every section.

> **Note:** The [Quickstart](https://mlavrinenko.github.io/mindtape/quickstart/index.md) goes from install to your first finished task. The [CLI reference](https://mlavrinenko.github.io/mindtape/cli/index.md) lists every command.
