Skip to content

feat: support monorepo workspaces in one pv.yml #365

Open

Description

@clvsh

Goal

Support a monorepo with one pv.yml at the repository root that describes multiple independently linked PV Projects. Ordinary single-project pv.yml files continue to work. Workspace members do not need config files in their own directories.

Proposed config

For a repository directory named shop:

primary: web
projects:
  web:
    path: apps/laravel
    php: "8.4"
    env:
      API_URL: "https://api.shop.test"
  api:
    path: apps/api
    php: "8.5"
    env_file: .env.local

pv link at the workspace root derives shop.test from the root directory and links the declared member paths. primary: web gives web the shop.test hostname; api gets api.shop.test. These are explicit Project hostnames. Other member keys become corresponding subdomains, without automatically exposing unlisted folders.

A top-level projects: identifies workspace config. Without it, PV parses the file as one normal Project. Each member uses the existing per-Project config fields and validation. Member path values are relative to the workspace root; each member's env_file and document root are relative to that member's path. The member key determines its generated subdomain, so moving a folder does not silently rename its URL.

Project and config ownership

  • Treat each member's canonical directory as its Project identity. Record the shared config file and member key with the linked Project so CLI commands and the daemon can find that member's settings.
  • Parse the single-project and workspace forms into the same per-Project model for serving, resources, status, and environment rendering.
  • Validate a workspace declaration before applying membership changes. A valid removal of a member entry unlinks that Project and removes its route while preserving Project data. An invalid config keeps the last valid working state and reports the error.
  • A declared member whose directory is deleted remains linked and is reported missing, following normal linked-Project behavior.
  • Continue allowing independently linked nested Projects. Current-directory lookup through SQLite chooses the nearest linked Project.
  • From a member directory, Project-aware commands and the PHP shim use that member's settings from the shared file; Composer continues through the PHP shim. At the workspace root, if it is not itself a linked Project, current outside-Project command behavior applies.
  • Config-writing commands such as pv php:use update the selected member in the parent file without creating a child pv.yml or changing sibling settings. Config readers and daemon reconciliation use the same member lookup.
  • Define pv unlink behavior for a member still declared in the workspace file so the CLI cannot silently leave SQLite and the file in conflict.

Acceptance criteria

  • Update DESIGN.md and user docs for the two config shapes and workspace lifecycle.
  • Integration tests cover one-file linking, key-derived hostnames, independent PHP/resource/env settings, nested current-directory resolution, and no child config files.
  • Integration tests cover php:use and PHP/Composer shim selection from member subdirectories, with writes confined to the correct member.
  • Integration tests cover valid member removal, invalid-config last-valid behavior, missing member directories, and independently linked nested Projects.

Related: #371 owns automatic wildcard subdomains and removal of hostnames:; #372 owns local HTTP proxy projects. This workspace feature can be implemented and verified with existing exact hostnames and PHP serving. The earlier bot implementation-plan comment on this issue describes the pre-split scope; this body supersedes it.

Activity

  1. pullfrog commented on Sep 26, 2026

    @pullfrog
    Contributor

    Assessment: Actionable, but cross-cutting. The current model reads pv.yml only from each Project root (crates/config/src/discovery.rs), persists one config_path per Project without a member selector (crates/state/src/database.rs), watches member directories (crates/daemon/src/watcher.rs), and assumes every served Project needs a PHP worker (crates/daemon/src/gateway.rs). DESIGN.md currently specifies explicit hostnames: and non-wildcard certificates, so the design contract must change before implementation.

    Plan

    1. Set the contract and config model. Update DESIGN.md first. Define strict workspace parsing (primary plus projects), member-key/relative-path validation, per-member ProjectConfig reuse, canonical member path identity, and a config-source reference (shared file plus member key). Keep ordinary pv.yml behavior. Define proxy: <port> as a mutually exclusive served mode with PHP serving, and reject hostnames: in both config shapes. Verify with config integration tests for valid shapes, unknown keys, collisions, path containment, and invalid ports/modes.
    2. Link and persist workspace members as a unit. Make pv link at a workspace root validate the complete declaration, derive <root>.test and <member>.<root>.test, then upsert members by canonical path in a transaction, preserving IDs, slugs, and resource data. Only after a fully valid edit should omitted workspace-owned members be unlinked; independently linked nested Projects must remain untouched. Store source membership independently of config_path, keep nearest-path lookup in SQLite, and watch each shared config file once, reconciling its members together. A missing member directory must remain linked and report missing rather than making the declaration invalid; malformed config must not partially unlink or overwrite last-valid state. Verify link/relink, rename/removal, parse-error recovery, missing directories, nested resolution, and rollback-safe migrations (the previous app must still read the database).
    3. Unify Project consumers and writers. Route daemon resource/env planning, CLI project:env/list/status, PHP and Composer shims, and php:use through the persisted config-source lookup. Resolve member env_file and document_root against its own path, not the workspace root. Update member entries in the shared file atomically while retaining sibling settings and file mode; audit pv init so it never silently creates child config for a linked member. Verify distinct PHP tracks, resources, env output, nested-directory shims, and member-only writes with no child config.
    4. Implement deterministic serving. Refactor Gateway planning to handle PHP-worker and loopback-proxy backends; a proxy must not allocate/start a PHP worker or supervise the target. Generate primary plus one-label wildcard routing and local-CA TLS for each served Project, including the matching PHP worker sites. Ensure an exact linked hostname wins over another Project's wildcard regardless of fragment/import order, while preserving Host and forwarding headers. Verify real HTTPS requests and certificate SANs for primary, wildcard, exact override, deeper-than-one-label non-match, and proxy target; exercise Caddy config reload/last-valid behavior.
    5. Remove alias behavior and finish documentation. Remove hostnames: parsing, selector/state/routing logic, and stale output/help references; retain only schema required for immediate-previous-version rollback per DESIGN.md. Update docs/user/README.md, CLI help/snapshots, and the certificate ADR to match the new contract. Run focused config/state/CLI/daemon integration tests, macOS Gateway/TLS tests, formatting and workspace Clippy.

    Decisions to confirm in the design step: I recommend requiring primary to name a declared member rather than silently choosing one, and rejecting pv unlink for a still-declared workspace member with instructions to remove its entry (otherwise the next reconciliation would relink it). Also define whether pv link --hostname is rejected at a workspace root, since the issue specifies directory-derived hostnames. These do not block planning, but should be settled before implementation.

    Task list (3/3 completed)

    Pullfrog  | Implement plan ➔ | View workflow run | via Pullfrog | Using GPT Sol | 𝕏

  2. pullfrog commented on Sep 26, 2026

    @pullfrog
    Contributor

    Run failed. View the logs →

    Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using GPT Sol | 𝕏

  3. changed the title [-]feat: support workspace projects, wildcard subdomains, and local proxy serving[/-] [+]feat: support monorepo workspaces in one pv.yml[/+] on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions