# The `.pumapack` file format (PumaShift, schema 1)

This document describes PumaShift's `.pumapack` files in enough detail to
**edit an existing export** or **generate one from scratch** so that it imports
cleanly. It is written for a reader, human or AI, who has no access to the app's
source.

A `.pumapack` is a UTF-8 JSON file. PumaShift writes two kinds, named in
`puma.kind`:

- a **board file** (`"kind": "board"`): one board. The topbar **Export** button
  writes it, and so does **Export this board** on a board tab's menu.
- a **backup** (`"kind": "backup"`): every board and every preference. **Back up
  everything** and ⌘S write it.

PumaShift reads them in two ways:

- **Import** (the topbar button, or dropping the file anywhere on the window)
  **adds**. A board file lands as a new board. A backup asks before it does
  anything. See §2.3.
- **Restore from backup…** (the ☰ menu or the ⌘K palette) replaces every board
  and preference with a backup's. See §2.4.

"Schema 1" is the envelope's `puma.format` number. PumaShift has no separate
data-schema version.

---

## 1. The short version

If you only read one section, read this one.

1. Wrap your board in the envelope from §2: `puma.app` must be `"pumashift"`,
   `puma.kind` should be `"board"`, and `data.boards` must be an array holding
   **exactly one** board. A file for someone else's browser is a board file.
2. Every person needs a `name` and a valid **IANA time zone** in `Region/City`
   form (`"Europe/London"`, not `"GMT+1"` or `"BST"`). Anything else becomes
   `"UTC"`, and the import says how many zones it could not read.
3. `start` and `end` are the person's **own local** wall-clock times, `"HH:MM"`,
   24-hour. An `end` at or before `start` runs past midnight. Equal times mean
   round the clock.
4. `days` are the weekdays a shift **starts** on, `0` = Sunday to `6` = Saturday.
   An **empty array means every day**, not never.
5. Colours are `"#rrggbb"`. Anything else becomes the default blue.
6. Person `id`s must be unique across the whole file. Give each board an `id`;
   it is how a later import recognises the board (§2.3).
7. Do not put a person's team in `tags`. The team goes in `team`; the app shows
   it as a tag by itself.
8. Check the result against the checklist in §9.

§10 is a complete, valid example you can copy and adapt.

---

## 2. The envelope

```json
{
  "$schema": "https://pumaworx.dev/pumapack/v1",
  "puma": {
    "app": "pumashift",
    "kind": "board",
    "appVersion": "generated",
    "format": 1,
    "exportedAt": "2026-10-14T09:00:00.000Z",
    "title": "Universal Exports"
  },
  "data": {
    "boards": [ /* board objects, §3: one in a board file, every board in a backup */ ],
    "active": "universal-exports",
    "roster": [ /* roster entries, §5 — written by the app, ignored on import */ ],
    "tag_groups": [ /* tag groups, §3.2 — likewise */ ]
  }
}
```

A backup has `"kind": "backup"`, `"title": "Backup"`, every board in
`data.boards`, and a `data.prefs` object (§2.5).

| Field | Required | Notes |
|---|---|---|
| `$schema` | no | Written as shown; not checked. |
| `puma.app` | **yes** | Exactly `"pumashift"`. |
| `puma.kind` | no, but write it | `"board"` or `"backup"`. Read first on import (§2.3). Any other value is refused. |
| `puma.format` | no | Write `1`. A higher number is refused: the file came from a newer PumaShift. |
| `puma.appVersion`, `exportedAt`, `title` | no | Informational. `title` is the board's name in a board file and `"Backup"` in a backup. |
| `puma.for` | no | Not written. A file whose `puma.for` names another app is a hand-off for that app and is refused, whatever it holds: *"This file is for PumaRisk. Import it there. Nothing was imported."* |
| `data.boards` | **yes** | Non-empty array of boards (§3). Exactly one when `kind` is `"board"`. |
| `data.active` | no | The open board's `slug`. Used by Restore; ignored by Import. |
| `data.roster`, `data.tag_groups` | no | For **other** apps (§5). PumaShift ignores both when it reads its own file. |
| `data.prefs` | no | Backups only (§2.5). Applied by Restore, never by adding a board. |

### 2.1 What the importer requires

A file is read as PumaShift's own when it parses as JSON and `puma.app` is
`"pumashift"`. A file with `data.boards` and **no** producer named at all (no
`puma.app`, no top-level `app`) is also read as PumaShift boards.

What it holds comes from `puma.kind`. A file with no `kind` (every file written
before PumaShift wrote one) is classified by shape: **one** board in
`data.boards` is a board file, and more than one is a backup.

The file is refused, with nothing changed, when `data.boards` is missing or
empty, when an entry in it is not an object, when `kind` is `"board"` and there
is not exactly one board, when `kind` is anything other than `"board"` or
`"backup"`, when `puma.format` is higher than `1`, or when `puma.for` names an
app other than `"pumashift"`.

Everything inside a board is **repaired rather than rejected**. A missing or
invalid field is replaced by its default, listed in §3 and §4. Nothing in a
board can make the import fail, so a mistake shows up as a wrong value on the
board, not as an error.

### 2.2 Other apps' packs

A file from another app is accepted when it carries a **roster** (§5), under
`data.roster` or, in a file with no `data`, at the top level. The app
names the producer, says how many people it will import, and lists what in that
file it will leave behind (ratings, roles, plans and so on). Then it asks. People
go onto the **open** board. See *Files this app accepts from other apps*.

A file from another app that holds people but no roster gets an explanation that
the export predates rosters, with how to re-export. Anything else is refused.

### 2.3 What Import does

**A board file** lands as **one new board**, which becomes the open one. The
boards already there are untouched.

- **Same `id` as a board already here.** The file is that board coming back,
  usually after an edit. PumaShift asks: **Replace "<name>"** overwrites that
  board with the file's copy, keeping its place in the tab strip; **Add as copy**
  adds it beside the original under a new id, with new person ids and a
  suffixed name (`"Nights (2)"`, then `"Nights (3)"`); **Cancel** changes
  nothing. Importing the same file twice therefore asks the second time; it
  never silently duplicates or overwrites.
- **Same name, different `id`.** Not the same board. It is added, with a
  suffixed name.
- **Otherwise** it is added under its own name and `id`.

The board's `slug` is re-derived from its name and made unique; the slug in the
file is not used. A board's `prefs` never travel, so adding someone's board
never changes your theme.

**A backup** is never restored silently. PumaShift asks: **Add alongside** adds
every board in it as if each were a board file, with any `id` collision resolved
as *Add as copy*, so nothing you have is touched; **Replace everything** goes to
Restore (§2.4); **Cancel** changes nothing. When the browser holds nothing yet
(one board with nobody on it), there is no question: the backup is restored.

### 2.4 What Restore does

**Restore from backup…** replaces **every board and preference** with the
backup's: the boards in the file's order, under their own `id`s and slugs, with
`data.active` open. When the browser holds anything, it asks first: **Back up
first, then restore** downloads a backup of what is there now and then
restores; **Replace without backing up** restores; **Cancel** changes nothing.
Restoring the same backup twice leaves the same state as restoring it once.

A board file chosen in Restore is not refused: it is **added**, as Import would,
and the toast says so.

### 2.5 The pack shapes

| Written by | `kind` | What it holds |
|---|---|---|
| **Export** (topbar) or **Export this board** (board tab menu) — `pumashift-<board-slug>-<YYYY-MM-DD>.pumapack` | `"board"` | One board, all of it (hidden people and its view included, never only what a filter shows); a `roster` of **that board's** people only; that board's `tag_groups`; **no `prefs`**. |
| **Back up everything** (☰ menu, ⌘K palette, or ⌘S), and the backup offered before a restore — `pumashift-backup-<YYYY-MM-DD>.pumapack` | `"backup"` | Every board; a `roster` of everyone on every board; the open board's `tag_groups`; `prefs`. |

`data.prefs` is:

```json
{ "theme": "dark", "accent": null,
  "display": { "clock24": true, "night": true, "coverage": true } }
```

On Restore a valid `theme` is applied; a valid `"#rrggbb"` `accent` replaces the
current one, and `null` puts back the app's own accent; `display` sets the
24-hour clock, the night shading and the overlap strip (only literal `false`
turns one off). **When you generate a file for someone else, write a board file
and leave `prefs` out.** A backup written before preferences moved into `data`
carries `prefs` at the top level, beside `data`; Restore reads it there too.

---

## 3. The board object

```json
{
  "id": "universal-exports",
  "slug": "universal-exports",
  "name": "Universal Exports",
  "accent_color": "#5b8af0",
  "created": "2026-10-14T00:00:00.000Z",
  "updated": "2026-10-14T00:00:00.000Z",
  "people": [ /* person objects, §4 */ ],
  "tagGroups": [ /* tag groups, §3.2 */ ],
  "view": { /* §3.1 */ }
}
```

| Field | Type | Default / repair |
|---|---|---|
| `id` | string, ≤ 64 | The board's identity: Import matches on it (§2.3). If missing, it is taken from `created` (the same `created` always gives the same id), or made up when that is missing too. |
| `slug` | string | Re-derived on import (§2.3). |
| `name` | string, ≤ 80 | `"Team"` if empty. |
| `accent_color` | `"#rrggbb"` | `"#5b8af0"` if invalid. |
| `created` | ISO 8601 datetime | The import time if missing. |
| `updated` | ISO 8601 datetime | The import time if missing. |
| `people` | array | `[]` if not an array. |
| `tagGroups` | array | The five default groups (§3.2) if missing or empty. |
| `view` | object | Filled in field by field (§3.1). |

### 3.1 `view`

The board's own reading state: two boards are two different questions.

```json
{ "date": null, "anchor": "UTC", "search": "", "onlyNow": false,
  "tags": [], "collapsed": [], "cursor": null }
```

| Field | Type | Meaning, and repair |
|---|---|---|
| `date` | `"YYYY-MM-DD"` or `null` | The day on screen, in the `anchor` zone. `null` = today. Anything else becomes `null`. |
| `anchor` | `"UTC"` or an IANA zone | The zone the 24-hour axis is read in. **Missing** means the reader's own zone; an **invalid** zone becomes `"UTC"`. Write it explicitly if the board should read the same for everyone. |
| `search` | string | The filter box. |
| `onlyNow` | boolean | *On shift now*. Only literal `true` counts. |
| `tags` | array of strings | Filter chips switched on (tag or team names). |
| `collapsed` | array of IANA zones | Zones folded to one row. |
| `cursor` | number or `null` | The marker, in **minutes from the start of the day on screen**, `0` to `1440`. Out of range is clamped; not a number becomes `null`. |

For a file you hand to someone, use the defaults shown above.

### 3.2 Tag groups

A tag group gives its tags a colour and a fixed order on every row.

```json
{ "id": "seniority", "name": "Seniority", "color": "#3fb8c2",
  "tags": ["Junior", "Mid", "Senior", "Lead", "Principal", "Manager"] }
```

- `id`: string, ≤ 64, unique within the board. A missing id gets a new one; a
  repeated id drops the later group.
- `name`: ≤ 60. `color`: `"#rrggbb"` or `""`.
- `tags`: ≤ 24 per group, each ≤ 40 characters. The reserved names `core`,
  `vacancy` and `contractor` are **removed** from any group: they always sort
  first and belong to no group.
- At most 24 groups per board.

The defaults are Affiliation (`extended`), Employment (`staff`, `apprentice`),
Seniority (as above), Location and Duty (both empty).

---

## 4. The person

```json
{
  "id": "ue6",
  "name": "Q",
  "tz": "Europe/London",
  "start": "07:00",
  "end": "15:00",
  "days": [1, 2, 3, 4, 5],
  "color": "#4ec98a",
  "team": "Q Branch",
  "note": "Return equipment in pristine order.",
  "hidden": false,
  "tags": ["core", "Principal"],
  "archived": false
}
```

| Field | Type | Default / repair |
|---|---|---|
| `id` | string | A new id if missing. Must be unique **across the file**: the roster and later imports match people on it. |
| `name` | string, ≤ 120 | `""`. Give everyone a name. |
| `tz` | IANA zone, `Region/City` | `"UTC"` if it is not that shape (an abbreviation such as `EST`, `BST` or `CET`, a fixed offset such as `GMT+1` or `Etc/GMT-5`) or the browser does not know it. `"UTC"` itself is accepted. The import toast counts the zones it replaced. |
| `start`, `end` | `"HH:MM"` | `"09:00"` / `"17:00"` if unreadable. |
| `days` | array of 0–6 | See §6.2. |
| `color` | `"#rrggbb"` | `"#5b8af0"` if invalid. |
| `team` | string, ≤ 60 | `""`. Shown as a tag and offered as a filter chip. |
| `note` | string, ≤ 500 | `""`. One line; shown in the editor and tooltips. |
| `hidden` | boolean | Kept off the board but still on the roster. Only literal `true`. |
| `tags` | array of strings | ≤ 24, each ≤ 40; duplicates by case dropped, first spelling kept. |
| `archived` | boolean | "No longer on the team", as another app reported it. Only literal `true`. |

`hidden` is a choice made in this app; `archived` is a fact from another app. An
archived person can be shown without being un-archived. When generating a file,
use `hidden: true` for anyone who should start off the board.

---

## 5. The roster (read by other apps)

Every PumaShift export also carries `data.roster`, a plain list of people that
other apps holding people (PumaSkills, for one) can read:

```json
{ "id": "ue6", "name": "Q", "tz": "Europe/London",
  "shift_start": "07:00", "shift_end": "15:00", "days": [1, 2, 3, 4, 5],
  "group": "Q Branch", "tags": ["core", "Principal"], "color": "#4ec98a",
  "description": "Return equipment in pristine order.", "archived": false }
```

It is the person object under other names: `start` → `shift_start`, `end` →
`shift_end`, `team` → `group`, `note` → `description`. `hidden` does not travel.
The team is **not** repeated in `tags`. `data.tag_groups` beside it carries the
vocabulary, so tags arrive with their colours and order.

PumaShift **ignores the roster in its own files**: the boards hold everything the
roster does and more. When generating a PumaShift file you may leave `roster` and
`tag_groups` out.

When PumaShift reads **another** app's roster (§2.2), an entry needs a non-empty
`name`. A person already on the open board, matched by `id` and then by name
regardless of case, is **updated**. Only fields the entry actually carries change,
so an entry can add or change a value but never blank one, and `archived: false`
is no news. Anyone else is **added**. A new person with no `days` works all seven,
and an archived person arrives hidden. A `tz` that is not a `Region/City` IANA
zone (§4) is no news for someone already on the board, who keeps their zone, and
`"UTC"` for someone new; the confirmation dialog names each such person and the
zone they arrived with before anything is imported. Tag groups merge by `id`, then by name, and
never replace the board's own.

---

## 6. Times, days and zones

### 6.1 Times

`start` and `end` are the person's local wall clock, `"HH:MM"`, 24-hour,
`"00:00"` to `"23:59"`. The app also reads `"9:00"` and `"0900"`, but write
`"HH:MM"`.

- `end` **after** `start`: a day shift.
- `end` **at or before** `start`: the shift crosses the person's midnight.
  `"22:00"`–`"06:00"` is eight hours, starting at 22:00 on its `days`.
- `end` **equal to** `start`: twenty-four hours.

A shift is a fixed length of time from its start, worked out for the date on
screen. On the night the person's own clocks change, a shift that spans the
change still lasts its usual number of hours.

### 6.2 Days

`days` lists the weekdays a shift **starts** on, in the person's own zone:
`0` Sunday, `1` Monday … `6` Saturday. A Friday night shift (`[5]`, `22:00`–`06:00`)
runs into Saturday morning without listing Saturday.

| You write | The app reads |
|---|---|
| `[1, 2, 3, 4, 5]` | Monday to Friday. |
| `[]` | **Every day.** |
| missing or not an array | Monday to Friday. |
| values outside 0–6 | Dropped; duplicates removed; sorted. |

### 6.3 Zones

Use an IANA name: `"America/New_York"`, `"Asia/Kolkata"`, `"Australia/Sydney"`,
`"UTC"`. The app works out every offset for the date on screen, including
half-hour and 45-minute zones and daylight-saving changes, so **never store an
offset**. A fixed `"Etc/GMT-1"` is valid but does not move in summer, which is
usually wrong for a person.

---

## 7. Editing an existing export

1. Start from the board's own **Export**. Importing it back asks whether to
   replace that board; choose **Replace**. To change everything at once, start
   from **Back up everything** and read it back with **Restore from backup…**.
2. Change only what you mean to. Keep the board's `id`, or the import adds a
   second board instead of offering to replace the first.
3. To add a person, give them a new, unique `id`.
4. To remove a person from a board, delete their object from that board's
   `people`. To keep them but take them off the board, set `hidden: true`.
5. Leave `roster` and `tag_groups` as they are, or delete them; PumaShift ignores
   both on its own import.
6. A backup is for its owner. Send anyone else a board file.

---

## 8. Things that go wrong

| Mistake | What actually happens |
|---|---|
| Not JSON | Refused: *"That file is not JSON, so there is nothing here to read."* |
| `puma.app` not `"pumashift"` and no roster | Refused: *"That is not a PumaShift board or backup, and it carries no roster."* (unless `data.boards` is present with no producer named; §2.1) |
| `data.boards` is `[]` | *"That PumaShift file holds no boards. Nothing was changed."* |
| `kind: "board"` with two boards | Refused. Write `"backup"`, or one board per file. |
| `puma.format` above `1` | Refused: the file came from a newer PumaShift. |
| `tz` as `"GMT+1"`, `"BST"`, `"EST"`, `"London"` | Becomes `"UTC"`; the toast reads *"… N time zones not read, set to UTC"*. The browser itself would accept `EST` (a fixed UTC−5 that never moves for summer) and `BST` (Bangladesh), which is why the app checks the shape rather than trusting it. |
| `start` as `"9am"` | Becomes `"09:00"`. |
| `days: []` meant as "none" | The person works **every** day. Use `hidden: true` instead. |
| Team written into `tags` | It appears twice on the row, and goes stale when the team is renamed. |
| `color` as `"blue"` or `"#58f"` | Becomes `"#5b8af0"`. |
| Two people with the same `id` | Both import; a later roster import matches only one of them. |
| Board's `id` changed | Added beside the original instead of offering to replace it. |
| `id` and `created` both missing | The board is added on every import. |
| A backup sent to someone else | Import asks them whether to add its boards or replace everything; only Replace everything applies your preferences. Send a board file instead. |
| `cursor` as `"14:00"` | Not a number, so no marker. Use minutes: `840`. |

---

## 9. Checklist before handing a pack over

- [ ] Valid JSON, UTF-8.
- [ ] `puma.app` is `"pumashift"` and `puma.kind` is `"board"`; `data.boards`
      holds exactly one board.
- [ ] The board has an `id`, a `name` and a `created` ISO timestamp.
- [ ] Every person has a unique `id`, a `name` and an IANA `tz`.
- [ ] `start`/`end` are `"HH:MM"` in the person's own local time.
- [ ] `days` uses 0 = Sunday; no empty array unless you mean every day.
- [ ] Colours are `"#rrggbb"`.
- [ ] No team names repeated in `tags`; no `core`, `vacancy` or `contractor` in
      a tag group.
- [ ] `view` left at the defaults in §3.1 unless you mean otherwise.
- [ ] No `prefs`: a board file carries none.

---

## 10. A complete example

A board file. Import adds it as a new board with no question and no warning:
three people in two zones, one of them on a night shift that crosses midnight.

```json
{
  "$schema": "https://pumaworx.dev/pumapack/v1",
  "puma": {
    "app": "pumashift",
    "kind": "board",
    "appVersion": "generated",
    "format": 1,
    "exportedAt": "2026-10-14T09:00:00.000Z",
    "title": "Universal Exports — skeleton staff"
  },
  "data": {
    "boards": [
      {
        "id": "ue-skeleton-staff",
        "slug": "skeleton-staff",
        "name": "Universal Exports — skeleton staff",
        "accent_color": "#5b8af0",
        "created": "2026-10-14T09:00:00.000Z",
        "updated": "2026-10-14T09:00:00.000Z",
        "people": [
          {
            "id": "ue-m",
            "name": "M",
            "tz": "Europe/London",
            "start": "08:00",
            "end": "18:00",
            "days": [1, 2, 3, 4, 5],
            "color": "#5b8af0",
            "team": "Head office",
            "note": "Reports on her desk by nine.",
            "hidden": false,
            "tags": ["core", "Manager"],
            "archived": false
          },
          {
            "id": "ue-leiter",
            "name": "Felix Leiter",
            "tz": "America/New_York",
            "start": "09:00",
            "end": "17:00",
            "days": [1, 2, 3, 4, 5],
            "color": "#b07ce0",
            "team": "Allies",
            "note": "CIA liaison, Langley.",
            "hidden": false,
            "tags": ["extended", "Senior"],
            "archived": false
          },
          {
            "id": "ue-bond",
            "name": "James Bond",
            "tz": "Europe/London",
            "start": "22:00",
            "end": "06:00",
            "days": [4, 5, 6, 0],
            "color": "#e06090",
            "team": "Double-O",
            "note": "Hours unverifiable.",
            "hidden": false,
            "tags": ["core", "Senior"],
            "archived": false
          }
        ],
        "tagGroups": [
          { "id": "affiliation", "name": "Affiliation", "color": "#5b8af0", "tags": ["extended"] },
          { "id": "seniority", "name": "Seniority", "color": "#3fb8c2",
            "tags": ["Junior", "Mid", "Senior", "Lead", "Principal", "Manager"] }
        ],
        "view": { "date": null, "anchor": "UTC", "search": "", "onlyNow": false,
                  "tags": [], "collapsed": [], "cursor": null }
      }
    ],
    "active": "skeleton-staff"
  }
}
```

---

## Files this app accepts from other apps

PumaShift reads one thing from another app's file: its **§60 roster**. Any
pack whose `data.roster` (or, in a file with no `data`, top-level `roster`) is
a non-empty array, and which is not PumaShift's own, is offered as a roster
(§2.2). The people are merged onto the open board, matched by `id` and then
by name; `data.tag_groups` beside them is merged into the board's tag
groups. PumaSkills writes a roster in every assessment export and backup:
in the §4 envelope (`puma.app: "pumaskills"`, `data.schema`,
`data.assessments`, `data.roster`, `data.tag_groups`) now, and with `app`,
`kind` and `schema` at the top level before that. Both are read the same
way. A file whose `puma.for` names another app is refused instead (§2.1).

---

## Older files this app still reads

Import and Restore read every shape PumaShift has written:

- **Backups with `prefs` at the top level**, beside `data`, and a `title`
  that counts the boards (`"2 boards"`). Saved as `pumashift-backup.pumapack`.
  Restore applies those preferences as it applies `data.prefs`.
- **No `puma.kind`.** Classified by the number of boards (§2.1).
- **No producer named.** A file with `data.boards` and no `puma.app` or
  top-level `app` is read as PumaShift boards (§2.1).
