# Configure a project with dryv.yaml

Usage is intentionally the simplest Dryv tier.

The user-facing project file is `dryv.yaml`. It connects an authored source or
serialized Runtime IR with active packs, project-specific bindings, logical
destinations, and build behavior.

It does not become another semantic authoring language.

## The usage contract

A project configuration should answer:

1. What software description are we using?
2. Which packs are active?
3. What does each pack require from this project?
4. Where should generated artifacts go?
5. How should this generation run?

## Example

```yaml
version: dryv/v1alpha1

sources:
  authoring:
    model:
      type: typescript
      path: dryv/contracts
      entrypoint: index.ts
  packs:
    local: { path: dryv/packs }

actions:
  format:
    stage: files
    extensions: [.ts]
    commands:
      - run: [bun, x, prettier, --write, $(files)]

destinations:
  ir:
    compiled: { path: .dryv/ir }
  models:
    path: src/_gen/models
    actions:
      - { $ref: "#/actions/format" }
  services:
    path: src/_gen/services
    actions:
      - { $ref: "#/actions/format" }

authoring:
  source: { $ref: "#/sources/authoring/model" }
  destination: { $ref: "#/destinations/ir/compiled" }

packs:
  models:
    source:
      $ref: "#/sources/packs/local"
      path: models
    destination: { $ref: "#/destinations/models" }

  service-contracts:
    source:
      $ref: "#/sources/packs/local"
      path: service-contracts
    destination: { $ref: "#/destinations/services" }

build:
  cache: reuse
  default_action: generate
```

The top-level `actions` registry defines reusable project commands. Each action
declares `stage: files` or `stage: final`. Each code destination selects actions
in an ordered list of explicit `$ref` entries to `#/actions/<id>`.
File actions run on staged generated files before comparison. Final actions
run after changed files are applied.

Dryv-owned keys use `snake_case`; Dryv-owned fixed values remain kebab-case or
dot-case. For keys you create, such as pack, template, selection and destination
names, prefer one word or kebab-case for two words (`entity-index`). Dryv
preserves these user-authored identifiers rather than rewriting them.

## Semantic source

A source can identify authored software that must be compiled by an Author
implementation, or it can identify serialized Canonical Runtime IR. Authored
source uses `path` for the source boundary and `entrypoint` for the compiler
entry file relative to that boundary.

The downstream runtime and pack model does not change based on which authoring
language originally produced the meaning.

## Packs

Projects can activate one or several packs.

Each pack remains responsible for declaring what it generates, what it selects,
what renderer capabilities it needs, and what options or bindings are required.

Usage chooses and configures packs. It does not redefine their selection logic.

## Project bindings

Reusable packs sometimes need project-specific values that cannot be portable
canonical meaning.

Those values belong in explicit project bindings or supported pack options, not
in hidden template conventions.

## Logical destinations

Destinations are resolved before real filesystem mutation.

That separation lets Dryv plan project-relative output while clients retain
control over the actual workspace.

Logical destinations make dry-runs, editor previews, remote execution, and safe
collision detection possible.

## Multiple packs

When several packs are active, Dryv must reason about the combined generation
plan.

The runtime should detect project-wide output conflicts rather than allowing one
pack to silently overwrite another pack's artifacts.

## Cache behavior

Usage can control supported cache modes independently from whether output is
applied.

Cache behavior must never change canonical meaning or hide an invalid plan.

## PostgreSQL partition layouts

Partitioning is canonical schema storage meaning under `facets.storage.partitioning`.
Declare it in the Author SDK or Runtime IR; project usage only supplies the connection
and pack activation. The owner explicitly changed the previous usage-only placement on
25 November 2026. There is one declaration authority and no usage override or compatibility
alias. All contracts remain v1alpha1.

```ts
storage("captures")
  .primaryKey("id", "capturedOn")
  .partitioning({
    strategy: "range",
    keys: ["capturedOn"],
    partitions: [],
    series: {
      start: "2026-01-01",
      end: "2027-01-01",
      unit: "month",
      name: "captures_{year}_{month}",
    },
  });
```

LIST supports one scalar key, as required by PostgreSQL. RANGE and HASH support ordered
composite `keys`. LIST bounds use scalar `values`; RANGE bounds are ordered `lower`/`upper`
tuples with the same arity as `keys`, with inclusive lower and exclusive upper bounds.
A null endpoint or trailing null tuple components mean MINVALUE/MAXVALUE. HASH bounds
use `modulus` and `remainder`; compatible mixed moduli are checked for divisibility and
overlap. Hash layouts cannot have a default partition. Explicit `default` bounds cover
otherwise uncovered LIST/RANGE values. Nested layouts are supported up to four levels
and 1024 physical children per logical table.

A bounded calendar `series` supports day, month and year units with a positive step.
Start/end dates and name placeholders (`{year}`, `{month}`, `{day}`) are explicit. Monthly
and yearly series start on calendar boundaries; the end must align with the chosen step.
The Engine expands the series deterministically without consulting a clock. Extending the
end produces additive migration steps for future partitions. No scheduler, automatic expiry,
implicit data deletion or distributed sharding is introduced.

Primary keys and unique indexes must contain all keys in the complete partition tree.
Composite references must include the target route keys; required companion fields let
one composite foreign key preserve the authored scalar relation. Nullable companions do
not silently replace stronger scalar enforcement. Canonical validation checks names, key
resolution/types, tuple arity, bounds, calendar intervals and effective key compatibility.
Physical child names are unique within their namespace, lowercase PostgreSQL identifiers
of at most 63 characters. SQL syntax and field naming variants remain pack responsibilities.

Capable persistence packs declare `capabilities.partitioning: true`. They receive the
normalized layout at `schema.facets.storage.partitioning`, with `keys` as NameContext lists
and parent-before-child flattened partitions; an aggregate projection is also available at
`pack.connection.partitioning`. SQL packs and migrations consume the same canonical layout.

Initial and additive SQL generation, exact numeric/UUID/timezone normalization, nested
parent ordering and catalog topology verification are supported. Converting populated tables,
changing/removing bounds or keys, or adding routes beside a populated default partition
requires an explicit reviewed migration intervention and verification. The Engine never
widens keys or moves/deletes existing rows implicitly. RANGE keys currently cover numeric,
date and timestamp values; expression keys, custom collations/operator classes and tablespaces
are outside the supported typed adapter. An inherited layout cannot be overridden.
