# Project configuration

Status: **proposed Usage-tier change caused by the pack-design redesign**

This document records the proposed `dryv.yaml` redesign that became necessary while designing reusable packs, generated units, action choices and destination-scoped command policy.

This is explicitly a **`dryv.yaml` / `dryv/v1alpha1` change**.

It is not a new semantic tier and does not change the Canonical Runtime IR.

All work remains on `v1alpha1`. Do not introduce `v1alpha2`.

## Why pack design changes usage

The pack design established several facts:

- several packs may contribute to one generated unit;
- the generated unit is represented by a destination;
- environment/tool choices belong to the destination, not to individual pack activations;
- pack repositories should be declared once and reused by several activations;
- authored source and serialized Runtime IR are both inputs to the same downstream pipeline;
- project wiring should remain visible and explicit.

The previous usage shape repeats source information inside pack activations and uses one top-level semantic `source`.

The proposed shape separates declaration from wiring.

## Structural model

The new usage file has four structural top-level sections:

```text
sources
destinations
authoring
packs
```

```yaml
version: dryv/v1alpha1

sources:
  authoring:
    <name>: ...
  packs:
    <name>: ...

destinations:
  ir:
    <name>: ...
  <name>: ...

authoring:
  source: { $ref: "#/sources/authoring/<name>" }
  destination: { $ref: "#/destinations/ir/<name>" } # only when compiling and emitting IR

packs:
  <activation>:
    source: { $ref: "#/sources/packs/<name>" }
    destination: { $ref: "#/destinations/<name>" }
    path: <pack path inside source>
```

The word `authoring` is intentional. Dryv's canonical tier is **Authoring**; `Author` remains the implementation/system role.

## 1. sources

Sources declare every external or project-local input Dryv reads.

They are grouped by role.

### Authoring sources

```yaml
sources:
  authoring:
    ir:
      type: ir
      path: dryv.ir.yaml

    model:
      type: typescript
      path: dryv/contracts
      entrypoint: index.ts
```

An authoring source is one of:

```text
type: ir
  serialized Canonical Runtime IR

type: typescript or python
  authored software that must be compiled into Runtime IR; path is the source boundary and entrypoint is relative to that boundary
```

The exact authoring-backend/compiler option contract remains owned by the Authoring design. Usage must identify the selected authoring implementation explicitly by source type; it must not infer one from file extensions.

### Pack sources

A pack collection is declared once:

```yaml
sources:
  packs:
    dryv:
      repository: https://github.com/dryvcode/packs
      ref: develop
      root: packs

    local:
      path: ./packs
```

Pack sources support the project-level repository mechanisms already required by Dryv:

- local path;
- public Git repository;
- private Git repository accessible through normal Git credentials.

No separate Dryv credential system is introduced.

For Git sources:

- `repository` identifies the repository;
- `ref` is the requested branch/tag/ref;
- `root` is an optional directory inside the repository containing the pack collection;
- exact resolved commit identity belongs in `dryv.lock`.

## 2. destinations

Destinations declare every output location.

They are grouped by content kind.

### IR destinations

```yaml
destinations:
  ir:
    compiled:
      path: build/ir
      name: dryv.ir
      formats: [yaml, json, jsonl]
```

An IR destination is valid only when an authored source is compiled and the project chooses to serialize the resulting Runtime IR.

Serialized IR is still owned by the Engine. Authoring implementations do not serialize it themselves.

### Code destinations

```yaml
destinations:
  backend:
    path: apps/backend
    choose: { js.package_manager: pnpm }

  api-client:
    path: packages/riderescue_api
    choose: { dart.sdk: dart }

  mobile:
    path: apps/mobile
```

A code destination is a generated unit.

It owns:

- the workspace path;
- destination-level `choose` selections;
- destination-level action replacements/overrides/disables.

All packs targeting one code destination share that destination's environment policy.

## 3. authoring

The `authoring` section chooses one declared authoring/IR source.

Serialized IR:

```yaml
authoring:
  source: { $ref: "#/sources/authoring/ir" }
```

Authored source with emitted IR:

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

Rules:

- `authoring.source` must reference `#/sources/authoring/...`;
- `authoring.destination` must reference `#/destinations/ir/...`;
- `destination` is invalid for `type: ir` because no compilation output exists to serialize;
- authored definitions compile to Canonical Runtime IR before pack planning;
- downstream pack planning is identical whether the IR came from authoring or was loaded directly.

Authoring-specific compiler/backend options remain an Authoring-contract concern and must not be invented by the pack design.

## 4. packs

Pack activations reference declared pack sources and code destinations.

```yaml
packs:
  entities:
    source: { $ref: "#/sources/packs/dryv", path: inject/persistence/typeorm }
    destination: { $ref: "#/destinations/backend" }

  validation:
    source:
      { $ref: "#/sources/packs/dryv", path: inject/validation/class-validator }
    destination: { $ref: "#/destinations/backend" }

  backend:
    source: { $ref: "#/sources/packs/dryv", path: unit/backend/nestjs }
    destination: { $ref: "#/destinations/backend" }
    inputs:
      package_name: "@riderescue/backend"
    bind:
      schema.validation: { $ref: "#/packs/validation" }
      schema.persistence: { $ref: "#/packs/entities" }
```

Existing pack-activation concepts remain:

- `inputs`;
- `bind`;
- explicit activation identity;
- one destination or an explicit destination-slot map for packs with several outputs.

The new source tree does not replace pack inputs or capability bindings.

## 5. Typed $ref wiring

Everything that consumes a source or destination refers to it explicitly.

Allowed prefixes:

| Use site                 | Required branch                     |
| ------------------------ | ----------------------------------- |
| `authoring.source`       | `#/sources/authoring/`              |
| `authoring.destination`  | `#/destinations/ir/`                |
| `packs.*.source`         | `#/sources/packs/`                  |
| `packs.*.destination`    | `#/destinations/<code destination>` |
| `packs.*.destinations.*` | `#/destinations/<code destination>` |
| `packs.*.bind.*`         | `#/packs/`                          |

A wrong branch is a validation error. Dryv never guesses what a reference meant.

Most `$ref` objects contain only `$ref`. A pack activation source also contains
`path`, because the reference chooses the pack collection and `source.path`
chooses the pack directory inside that collection.

## 6. Destination-level choices and actions

Pack design makes this part of `dryv.yaml`.

```yaml
destinations:
  backend:
    path: apps/backend
    choose: { js.package_manager: pnpm }

    actions:
      files:
        format:
          commands:
            - run: [pnpm, exec, biome, format, --write, $(files)]

      final:
        install:
          commands:
            - run: [pnpm, add, --save-exact]

        typecheck:
          disable: true
```

Rules from pack design remain authoritative:

- destination `choose` selects among compatible pack candidates;
- a destination action replacement changes only fields it supplies;
- omitted `extensions`, `dependencies`, `after`, `name` and `description` remain inherited from the merged pack action;
- unknown action IDs are errors;
- action configuration is unit-scoped, not workspace-global.

## 7. Full IR-based example

```yaml
version: dryv/v1alpha1

sources:
  authoring:
    ir: { type: ir, path: dryv.ir.yaml }

  packs:
    dryv:
      repository: https://github.com/dryvcode/packs
      ref: develop
      root: packs

destinations:
  backend:
    path: apps/backend
    choose: { js.package_manager: pnpm }

  api-client:
    path: packages/riderescue_api
    choose: { dart.sdk: dart }

  mobile:
    path: apps/mobile

authoring:
  source: { $ref: "#/sources/authoring/ir" }

packs:
  entities:
    source: { $ref: "#/sources/packs/dryv", path: inject/persistence/typeorm }
    destination: { $ref: "#/destinations/backend" }

  validation:
    source:
      { $ref: "#/sources/packs/dryv", path: inject/validation/class-validator }
    destination: { $ref: "#/destinations/backend" }

  backend:
    source: { $ref: "#/sources/packs/dryv", path: unit/backend/nestjs }
    destination: { $ref: "#/destinations/backend" }
    inputs:
      package_name: "@riderescue/backend"
    bind:
      schema.validation: { $ref: "#/packs/validation" }
      schema.persistence: { $ref: "#/packs/entities" }

  api-client:
    source:
      { $ref: "#/sources/packs/dryv", path: package/clients/dart-api-client }
    destination: { $ref: "#/destinations/api-client" }
    inputs:
      package_name: riderescue_api

  mobile:
    source: { $ref: "#/sources/packs/dryv", path: project/frontend/flutter-app }
    destination: { $ref: "#/destinations/mobile" }
    inputs:
      app_name: riderescue
    bind:
      operation.client: { $ref: "#/packs/api-client" }
```

## 8. Authored-source example

```yaml
version: dryv/v1alpha1

sources:
  authoring:
    model:
      type: typescript
      path: dryv/contracts
      entrypoint: index.ts

  packs:
    dryv:
      repository: https://github.com/dryvcode/packs
      ref: develop
      root: packs

destinations:
  ir:
    compiled: { path: build/dryv.ir.yaml }

  backend:
    path: apps/backend
    choose: { js.package_manager: pnpm }

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

packs:
  backend:
    source: { $ref: "#/sources/packs/dryv", path: unit/backend/nestjs }
    destination: { $ref: "#/destinations/backend" }
```

If `authoring.destination` is omitted, Runtime IR may remain in memory for planning/generation.

## 9. dryv.lock

The usage redesign introduces a generated reproducibility companion:

```text
dryv.yaml
  human-authored project intent and allowed source refs

dryv.lock
  exact resolved source/compiler/pack identities
```

Conceptual shape:

```yaml
version: dryv.lock/v1alpha1

authoring:
  backend:
    id: dryv.typescript
    version: 0.9.4
    digest: sha256:...

sources:
  packs:
    dryv:
      commit: 3f9c2a1e...
  authoring:
    model:
      digest: sha256:...

packs:
  backend:
    digest: sha256:...
  entities:
    digest: sha256:...
```

Rules:

- generated by Dryv, not handwritten;
- intended to be committed with the project;
- Git sources resolve requested refs to exact commits;
- local sources may record content digests;
- pack contents may record digests;
- authoring implementation identity/version may be locked;
- the Engine validates lock compatibility before reproducible generation.

Exact lock hashing and update-command behavior still require implementation design.

## 10. This is a Usage-tier change

The pack model caused this redesign, but the fields in this document belong to Usage.

Do not implement them in:

- Runtime IR;
- Authoring Protocol;
- pack semantic vocabulary;
- template-server contracts.

They belong to:

```text
dryv/v1alpha1
dryv.yaml
dryv.lock/v1alpha1
```

The architectural boundary remains:

```text
Authoring source / serialized IR
        ↓
dryv.yaml source wiring
        ↓
Canonical Runtime IR
        ↓
pack selection/planning/actions
        ↓
code destinations
        ↓
Client applies output and executes approved commands
```

## 11. Intentionally not copied from the external proposal

The following ideas are **not** adopted as pack-design facts:

- a project pack does not imply a managed package manifest;
- managed/scaffold ownership still comes from actual resource ownership such as `.sf`;
- a destination does not declare a `choose` value when no pack action offers a real choice;
- pack-map order must not carry required semantic ordering; required action order uses `after`;
- compiler-specific option names are not invented by Usage before Authoring defines them.

## 12. Existing build settings

The current usage contract has a `build` section.

This redesign focuses on project wiring and does not silently redefine cache/default-action behavior.

Before implementation, decide whether current build settings:

- remain as an additional orthogonal Usage section; or
- move entirely to CLI/client configuration.

Do not drop them accidentally merely because the structural examples above focus on `sources`, `destinations`, `authoring` and `packs`.

## 13. Design fixtures

Concrete examples in this workspace:

- fullstack-monorepo.dryv.yaml — serialized IR plus several code destinations;
- authored-project.dryv.yaml — authored source plus optional IR emission;
- project-actions.dryv.yaml — destination-scoped `choose` and selected project actions;
- fullstack-monorepo.dryv.lock — conceptual generated lock companion.

These are design fixtures only. The current stable Usage contract and implementation still use the existing shape until this redesign is approved for implementation.
