Skip to content

Merge stacks-2 into stacks-3 - #125

Merged
davidjalbers merged 58 commits into
stacks-3from
stacks-3-sync
Dec 6, 2026
Merged

davidjalbers merged 58 commits into
stacks-3from
stacks-3-sync

Conversation

@davidjalbers

@davidjalbers davidjalbers commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Known: a newborn with a stack fails plx doctor until the next issue (PLX-303).
The stack template writes production.yaml and staging.yaml by name while the repo declares no environment, so PLX-Stack/FileNamesDeclared refuses both files, and mise run check of such a repo fails with it.
The newborn and unit tests that need such a repo to pass declare the two names (STACK_FILE_ENVIRONMENTS in newborns/helpers.ts, FILE_ENVIRONMENTS in newSite.test.ts), and one test, in newSite.test.ts, states the defect: a newborn with a stack and no declaration fails the doctor for both files.
PLX-303 renders the files from the declaration, turns that test round and removes the declarations.

Merges origin/stacks-2 (61d97da, milestone 2) into stacks-3.
Conflicts in eight files; the branch map is the declaration's, everything else of milestone 2 is kept.

Per file

  • packages/lib/src/deployTargets.ts: milestone 2's file, holding no inventory reading, DEFAULT_ENVIRONMENT or ENVIRONMENT_BRANCHES, with environmentOf(declared, event, ref, given) from the declaration.
  • packages/lib/src/deployTargets.test.ts: the tests of environmentOf from the declaration; the inventory tests went with the code they covered.
  • packages/lib/src/index.ts: environmentOf is the one export of deployTargets.ts; every other export of both sides stays.
  • packages/lib/src/standard-index.json: the union of both sides' additions (PreparedHost, FileNamesDeclared, DeclaredHasFile), without PathPrefix and PrefixInRecord.
  • packages/cli/src/commands/deploy.ts: milestone 2's header (no --inventory) with the branch "a declared env/ branch"; the declaration read and its refusal are as they were.
  • packages/cli/src/commands/deploy.test.ts: both tests kept: the declaration refusals, now without --inventory, and the unknown --inventory option through plxProcess.
  • packages/cli-ci/src/commands/setupWithoutToken.test.ts: milestone 2's title and cases; both jobs that run on_push are given the marker that declares environments.
  • newborns/update-released.test.ts: both tests kept.

Fixtures the merge made stale (added commits, tests only)

The stack template renders production.yaml and staging.yaml, and plx doctor now fails a file whose environment the root marker does not declare.
So a newborn with a stack and no declaration fails the doctor (PLX-Stack/FileNamesDeclared).
The fixtures that keep those files declare the two names: newborns/pipeline.test.ts, newborns/repo-operations.test.ts (the deploy job), newborns/app-nextjs.test.ts, newborns/e2e-playwright.test.ts and packages/lib/src/newSite.test.ts (bornTurbo).
origin/stacks-3 (1a99506, promote and release) is merged in as well, without a conflict.
No case is dropped.

Left for the next issue (PLX-303)

  • The stack template's literal production.yaml and staging.yaml (a stack is born with files for two names whatever the repo declares).
  • The operations workflow's plx deploy --environment production, and its deploy-production concurrency group and header.
  • The app repo workflows on_push and on_commit naming main and develop.
  • The trigger branches: [main] of the operations deploy.yml.jinja.
  • renovate/operations.json ("deploys ... to production") and stack/files/PLEXUS.md.jinja line 7.
  • setup.ts near line 81: the refusal covers on_push only, not the operations repo's deploy workflow.
  • The newborn tests still on develop: pipeline.test.ts, deploy-job.test.ts, update-released.test.ts.
  • The fixture declarations above, to be removed.
  • The wording in PLEXUS.md.jinja of the operations template ("into production").
  • No new refusal or message was needed in milestone 2's code: it asked no branch map.
    plx-ci setup's deploy job refuses a push on a branch no environment is declared for, as the repo job does; two fixtures of milestone 2 ran it without a marker and now carry one.

Verification

  • plx requirements . --compendium <the compendium's stacks-3>: citations resolve, nothing found.
  • Newborn files through scratch.ts after mise run build and node newborns/pack.ts: deploy-job, repo-operations, update-released, pipeline: 47 of 47 pass.
  • TURBO_FORCE=true mise run test: exit 0, Tasks: 7 successful, 7 total, Finished in 370.97s.

🤖 Generated with Claude Code

davidjalbers and others added 30 commits December 6, 2026 01:59
…epo is

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… update lands on it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A repo's kind no longer decides the branch: it is read from origin/HEAD of the
checkout, else from origin's own HEAD, and a repo with neither is skipped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… stale record

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…their default

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Every case hands the playbook an environment's file instead of a directory
the platform laid out: the playbook creates the directory and writes .env
from `env`, and .env.secret from `secrets` through a stand-in of the vault's
CLI. New cases: values and secrets reach the containers byte for byte and no
secret reaches the output, with -v or --diff; a changed value beside a
rotated secret that breaks the healthcheck ends with the previous .env,
.env.secret, compose.yaml and containers; a secret the vault does not hold;
files the playbook cannot write; a dry run of a new environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er cites; ship regenerates the file at the cut

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The playbook takes the environment's file (stack_environment_file) in place
of the environment's name and an inventory: a first play where it runs reads
the file, refuses one it cannot write faithfully, resolves each pointer under
`secrets` with `op read`, and adds the host `host` names, as the user it names
or plexus_deploy_user, which the role deploy_user now gives a default. On the
host it creates the environment's directory, writes .env from `env` with the
project name and .env.secret from the secrets, each value double-quoted and
escaped so that Compose reads it back as written, keeps the previous copy of
each of the three files that changes, and on a failed deploy restores them
together. No task that holds a secret prints it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
host-image.sh builds what platform-playbook.sh built for itself, with
Docker's CLI and compose plugin and PyYAML added, and Caddy without a site,
so that it listens on nothing until the platform playbook configures it. The
platform playbook's test mounts its stand-in for docker over the CLI; the
stack playbook's test will run the real one against this machine's daemon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… prepared host

A second part runs the playbook against a host the platform playbook
prepared, a container booted with systemd in this machine's network, whose
proxy listens on 127.0.0.1 and ports of the run's own: a first deploy takes
the lowest port of the range and writes the route, which serves the
environment and refuses /healthz; a run in which nothing changed changes no
file and reloads nothing; two first deploys started at once end with
different ports; a hostname another environment serves is refused; a changed
value that breaks the healthcheck is rolled back and its route kept; a port a
directory holds is kept; no free port; a route the proxy refuses; a dry run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Where the environment has a hostname, files/route.sh runs on the host under
one lock file under /opt/stacks, which a second deploy waits for: it refuses
a hostname another environment's fragment serves, keeps the port the
environment's .env names or takes the lowest of stack_port_range
(20000-20999) that no other .env and no other fragment names, and writes the
route fragment and reloads the proxy only where the fragment's text changes,
putting back what was there where the proxy refuses. .env carries the port as
PLEXUS_LOOPBACK_PORT. A rollback restores the files and leaves the route,
which joins the hostname to a port that does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e-lands-a-version-on-develop

plx update lands a version on the default branch of origin
…or a released name as a citation

The maintainer removed path prefixes: a deviation under PLX-Stack/PathPrefix has no meaning the index of an older version could still give it, so the test of released names holds only the renamed one, spelled at run time.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Path prefixes are gone by the maintainer's decision; the requirement's name stays in the index of the last version until the next one is cut, and nothing here cites it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… file, with no inventory

Each stack's file for an environment names its host; the playbook is handed the file and no inventory, user, port or environment name, an environment file with a problem refuses the run before any host, and --inventory is an unknown option.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ecret, nothing from the vault, no token for a second repo

Setup holds the key in an agent, puts op on the PATH for the playbook that reads the secrets, and reads the vault only to join the overlay; --operations-repo is gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…holds the two repository secrets of a deploy

The step of plx deploy holds the read-only vault token, setup holds the deploy key, and no step names an operations repo or an inventory.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e host the file names, and reads no inventory

The stack playbook gets the file and no inventory, user, port or environment name; a file with a problem refuses the run before any host or registry; --inventory is gone with the operations record the deploy targets read, and deployTargets.ts keeps only the map from a branch to its environment.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ads nothing from the vault and mints no token for a second repo

It puts op where the stack playbook finds it, reads the vault only to join the overlay, and no longer knows an operations repo: --operations-repo, operations-token and isOperationsRepo are gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…y and the vault token as repository secrets

The workflows hand setup DEPLOY_SSH_KEY and the step of plx deploy DEPLOY_VAULT_TOKEN as its OP_SERVICE_ACCOUNT_TOKEN; the CI vault's token reaches setup only to join the overlay. repo-operations renders no plexus_apps, plexus_up or plexus_deploy_root, and names no tag the platform playbook dropped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eploy, with host, hostname, env and secrets

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r environment files, with the deploy key a secret of the repo

The stand-in playbook takes its host from the file, setup reads nothing from the vault, and the verb has no inventory.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ch the doctor passes as born

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eploy: host, hostname, env and secrets

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…onment file, with no inventory

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
davidjalbers and others added 25 commits December 6, 2026 05:12
…mpty or does not answer

An environment whose last secret is dropped deploys, under --check too:
.env.secret stays, empty and 0600, the services that loaded it are
re-created, and a second run changes nothing. A value the vault holds empty
is refused, naming the pointer; a read that does not answer within
stack_secret_timeout is refused, naming the usual cause, and leaves no op
running. The vault CLI's stand-in waits for a pointer ending in /locked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…et, and gives op read a timeout

The template lookup gives none rather than an empty string for an
environment without secrets, so writing .env.secret after the last secret
was dropped failed, and the dry run's undo failed with it: the text is now
an empty string, and a dry run, which wrote nothing, undoes nothing. Each
op read runs under the Python that runs Ansible, which kills op after
stack_secret_timeout seconds (30) and says that it mostly waits for an
unlock nobody answers; a value the vault holds empty is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with a line break

A run given --limit, --tags or --skip-tags fails with a Result line that says
the playbook takes none of them, since each leaves out the deploy or the line
that says how it ended. A host or a hostname whose text ends in a line break
is refused with the environment's file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing in a line break

Every task is tagged always, so that the first, a check of the arguments,
runs under --tags too, and refuses a --limit, --tags or --skip-tags with a
Result line: each would leave out the deploy, or the line that says how it
ended. The forms of host and hostname end in \Z, where $ let a trailing
line break pass, and the route script's arguments are quoted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ostname of an earlier version's routes

The prepared host carries a route of an earlier version in apps.caddy, as a
host in migration does. A new environment claiming its hostname ends refused
with the proxy's own reason, its fragment gone and nothing else written; an
environment whose fragment changes to it ends with the fragment as it was. A
port of the range that something on the host listens on is skipped. A
fragment that does not parse gives caddy validate's reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…proxy refused

A new port skips every port in state LISTEN that /proc/net/tcp and
/proc/net/tcp6 list, which every Linux host has, so that a first deploy does
not claim a port it cannot bind and keep it for good. Where the proxy
refuses the reload, the line gives the error of caddy validate, which the
deploy user can run, instead of a cause the script does not know; where that
says nothing, only that the proxy refused. A host without flock is told so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… what its caller must know

deploy_user_root, in the role deploy_user's vars, which no inventory
overrides, is the one place /opt/stacks is written: the role's task uses it,
and the stack playbook reads the file for stack_root's default, which -e
still overrides. The header says that the caller passes no -i, --limit,
--tags or --skip-tags, and which runs of no task Ansible ends with exit 0
and no Result line; that PLEXUS_TAG and PLEXUS_COMMIT_SHA are rendered into
the compose file by the caller; that .env.secret ends empty once the
environment has no secrets, and .env.secret.prev keeps the previous ones;
and step 3 points at the route script's header instead of repeating it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut whose path has a space and an =

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the loader's refusal as it wrote it and names the missing vault secret in CI

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e requirement was removed

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…is told the requirement was removed; the index names neither

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… update

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…dded by an update

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…irth renders both

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… none to a stack born without them

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…from an update, and one a person wrote stays

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…o davidjalbers/plx-299-plx-deploy-plx-ci-setup-and-the
…failure

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… runs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d requirements are listed by module and suffix

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…y-plx-ci-setup-and-the

plx deploy, plx-ci setup and the templates read environment files (PLX-299, with PLX-298)
Resolved, per file:

- packages/lib/src/deployTargets.ts: milestone 2's file (the inventory reading is gone, and so are DEFAULT_ENVIRONMENT and ENVIRONMENT_BRANCHES) holding only environmentOf, which is the declaration-based one (declared, event, ref, given).
- packages/lib/src/deployTargets.test.ts: the tests of environmentOf from the declaration; the inventory tests went with the code they covered.
- packages/lib/src/index.ts: exports only environmentOf from deployTargets.ts; every other export of both sides is kept.
- packages/lib/src/standard-index.json: the union of both sides' additions (PreparedHost, FileNamesDeclared, DeclaredHasFile), without PathPrefix and PrefixInRecord, which milestone 2 removed.
- packages/cli/src/commands/deploy.ts: milestone 2's header examples (no --inventory) with the branch "a declared env/<name> branch"; the declaration read and the refusal were already merged.
- packages/cli/src/commands/deploy.test.ts: both tests kept: the declaration refusals (without --inventory) and the unknown --inventory option through plxProcess.
- packages/cli-ci/src/commands/setupWithoutToken.test.ts: milestone 2's title and cases, the first job given the marker that declares environments.
- newborns/update-released.test.ts: both tests kept (the declaration stands as written; the stack gets no environment file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ging files declare those two environments, as the doctor now requires

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ts its stack template files stand for, as the doctor now requires

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r that declares environments, as its first job is

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@davidjalbers davidjalbers self-assigned this Dec 6, 2026
davidjalbers and others added 2 commits December 6, 2026 09:18
The merge of the promote and release pull request is clean: no file conflicted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… files stand for, from one constant, and one test says that a repo declaring none fails the doctor for both files

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@davidjalbers
davidjalbers merged commit cd3770f into stacks-3 Dec 6, 2026
2 checks passed
@davidjalbers
davidjalbers deleted the stacks-3-sync branch December 6, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant