# Catalog file (patchbay.yaml)

> The format of patchbay.yaml, version v1alpha1: fields, validation rules and findings.

## Scope

A **catalog file** is exactly `patchbay.yaml` at the root of a GitHub
repository's default branch. A standalone file names the project and treats
the repository itself as the component (`components` is omitted). A monorepo
file lists subdirectory components:

```yaml
apiVersion: patchbay.unbrikd.cloud/v1alpha1
kind: ProjectCatalog
project: <workspace>/<project>
components:
  - name: <component-name>
    rootPath: <repository-subdirectory>
    description: <text>                       # optional
```

The file targets exactly one project in the workspace performing discovery.
Every component declaration belongs to the repository containing the file.
v1alpha1 has no configurable filename, branch, provider, ownership,
dependencies, lifecycle, tags, links, or cross-workspace targets.

## Field contract

The YAML document is a mapping. The file and each component mapping allow
exactly these fields:

<Tabs>
<Tab title="File">

| Field | Type | Required | Contract |
|---|---|---:|---|
| `apiVersion` | string | yes | Exactly `patchbay.unbrikd.cloud/v1alpha1`. |
| `kind` | string | yes | Exactly `ProjectCatalog`. |
| `project` | string | yes | Exactly one `<workspace>/<project>` target. |
| `components` | sequence | no | Absent means standalone (the repository is the component). When present, one or more component mappings, each with a subdirectory `rootPath`. |

</Tab>
<Tab title="Component">

| Field | Type | Required | Contract |
|---|---|---:|---|
| `name` | string | yes | Non-empty, 255 characters or fewer, no leading/trailing whitespace. Preserved and compared case-sensitively. |
| `rootPath` | string | yes when `components` is present | Repository-local subdirectory. `/` and an omitted path are not allowed. |
| `description` | string | no | Preserved as authored. Omission means no desired description. |

</Tab>
</Tabs>

Scalar coercion is not allowed: numbers, booleans, and null are not strings.
Unknown fields at either level fail. YAML merge keys and aliases cannot add or
replace fields. Duplicate mapping keys fail before field validation. The file
must contain exactly one YAML document. Comments are allowed.

### Project target

`project` contains one slash and no surrounding whitespace.

- `workspace` is the canonical workspace slug: 2-50 lowercase ASCII letters,
  digits, or hyphens. It starts and ends with a letter or digit.
- `project` is the persisted canonical project name: 1-35 lowercase ASCII
  letters, digits, hyphens, or underscores and is not one of `new`, `create`,
  `settings`, `admin`, `api`, `system`, `internal`, `public`, or `private`.
- The workspace segment must equal the workspace in which the source GitHub
  installation is active. A syntactically valid different workspace is a
  target-mismatch finding and is never followed across the tenant boundary.

After a workspace slug rename, Patchbay ignores a file that still names the
old slug until the file uses the new one.

The file contains one scalar target, not a target list. A missing or malformed
target is rejected rather than inferred from repository ownership.

### Root path normalization

Patchbay normalizes paths without reading repository contents:

1. A standalone file (no `components`) declares one component, named after the
   project and rooted at `/`.
2. When `components` is present, every entry must supply `rootPath`.
3. A supplied value must not be empty. It must not contain leading or trailing
   whitespace, a backslash, NUL or control characters, an interior empty
   segment, or `.` or `..` segments.
4. `/` is rejected in a `components` list. The repository root is the
   standalone shape, not a monorepo component.
5. One optional leading slash is removed from a non-root path, then one leading
   slash is added. `/apps/api` and `apps/api` therefore normalize to
   `/apps/api`. Comparison is case-sensitive and no URL decoding or
   Unicode normalization is performed.

Each component in a file needs its own root path and its own name, because
every component in the file belongs to the same repository. When two
components clash, Patchbay reports the later one.

## Valid examples

<Tabs>
<Tab title="Standalone repository">

Omit `components`. The project name is the component name and the root path
is `/`.

```yaml
apiVersion: patchbay.unbrikd.cloud/v1alpha1
kind: ProjectCatalog
project: acme/payments
```

</Tab>
<Tab title="Monorepo">

Every component pins a subdirectory.

```yaml
apiVersion: patchbay.unbrikd.cloud/v1alpha1
kind: ProjectCatalog
project: acme/commerce
components:
  - name: storefront
    rootPath: /apps/storefront
    description: Customer-facing storefront.
  - name: checkout-api
    rootPath: apps/checkout-api
  - name: shared-contracts
    rootPath: /packages/contracts
    description: Shared API contracts.
```

The canonical paths are `/apps/storefront`, `/apps/checkout-api`, and
`/packages/contracts`.

</Tab>
</Tabs>

## Problems Patchbay reports

When a file breaks a rule, Patchbay applies nothing from it. Each problem
shows in the catalog settings of the project and in the inbox. Each problem
names the field it is about, such as the second component's `rootPath`, so you
can find the line to fix.

<Tabs>
<Tab title="File">

| Problem | Fix |
|---|---|
| The file is not valid YAML, or it is not a mapping. | Check the indentation and make the top level a set of `key: value` fields. |
| The file has more than one YAML document. | Remove the extra document that starts after a `---` line. |
| The file is larger than 256 KiB. | Shorten the file, for example its descriptions. |
| A field is not supported, or a field appears twice. | Remove the field or the repeated key. |
| The file uses YAML aliases or merge keys. | Write each value out in full. |

</Tab>
<Tab title="Version and kind">

| Problem | Fix |
|---|---|
| `apiVersion` is missing, is not a string, or is not supported. | Set `apiVersion: patchbay.unbrikd.cloud/v1alpha1`. |
| `kind` is missing, is not a string, or is not supported. | Set `kind: ProjectCatalog`. |

</Tab>
<Tab title="Project">

| Problem | Fix |
|---|---|
| `project` is missing. | Add `project: <workspace>/<project>`. |
| `project` is not a valid target. | Use the workspace slug and the project name, in lowercase, with one slash. |

</Tab>
<Tab title="Components">

| Problem | Fix |
|---|---|
| `components` is not a list, or the list is empty. | List at least one component, or remove `components` for a standalone repository. |
| A component entry is not a mapping. | Give each entry a `name` and a `rootPath`. |
| A component name is missing, too long, has extra spaces, or repeats another name. | Give each component a unique name of 255 characters or fewer. |
| A root path is missing, is the repository root, or repeats another path. | Give each component its own subdirectory. |
| A root path has unsafe characters or segments, such as `..`. | Use a plain folder path, such as `/apps/api`. |
| A description is not a string. | Quote the description. |

</Tab>
<Tab title="Conflicts">

| Problem | Fix |
|---|---|
| The name belongs to a component at another location. | Give the declaration a name that no other component of the project uses. |
| The location belongs to a component with another name. | Use the name of the component at that location, or point the declaration at another folder. |

</Tab>
</Tabs>

## How Patchbay applies the file

Patchbay reads `patchbay.yaml` only from repositories that an active GitHub App
installation exposes to the workspace. The file is limited to 256 KiB.

A project administrator must turn on **Catalog sync** for an existing project. A
file that targets a project that does not exist creates a project proposal for
workspace owners and administrators.

Reconciliation is additive. It compares each declaration with the project's
components by exact name and by location (repository and normalized root path):

| Current project state | Result |
|---|---|
| No component has the name or location | Patchbay creates a catalog-managed component. |
| A catalog-managed component has the same name and location | Patchbay updates its description. |
| A manual component has the same name and location | No change. A project administrator can adopt it. |
| A component has the name at another location | Patchbay reports a conflict and changes nothing. |
| A component has the location under another name | Patchbay reports a conflict and changes nothing. |

Patchbay never renames, moves, or deletes a component from a catalog file. When
a declaration disappears, its catalog-managed component is marked stale and
stays available. An invalid file applies nothing. The last valid declarations
stay in effect. Changes to components do not rewrite existing releases.

Index of all pages: https://patchbay.unbrikd.com/docs/llms.txt
