Skip to content

Version Packages - #60

Merged
CopilotKit merged 1 commit into
mainfrom
changeset-release/main
Oct 28, 2023
Merged

CopilotKit merged 1 commit into
mainfrom
changeset-release/main

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@copilotkit/[email protected]

Minor Changes

  • 0467f62: minor ergonomic improvement to CopilotProvider instantiation

@copilotkit/[email protected]

Patch Changes

@copilotkit/[email protected]

Patch Changes

[email protected]

Minor Changes

  • 0467f62: minor ergonomic improvement to CopilotProvider instantiation

Patch Changes

@CopilotKit
CopilotKit merged commit 7b5f08e into main Oct 28, 2023
@CopilotKit
CopilotKit deleted the changeset-release/main branch October 28, 2023 15:54
dongphuongman pushed a commit to dongphuongman/CopilotKit that referenced this pull request Oct 24, 2026
…to the requested service (CopilotKit#7955)

**Decision owner: Mark (CPK-8652 / Showcase prod recovery). Do not merge
without his review.**

This is a proposal. Nothing was dispatched or deployed.

## Problem

CPK-8652 says that staging's harness and harness-workers must not be
promoted to prod. But `showcase_promote.yml` cannot promote a demo
service without them:

- `resolve-promote-targets.sh` always adds every Tier-1 service
(dashboard, harness, harness-workers) to the closure. This happens even
for `service=showcase-aimock`. The workflow has no input to leave a
service out.
- `promote-fleet.sh` sent `--digest <ref>` to **every** service in the
closure. `bin/railway` accepts a digest for its positional service, and
promote-fleet calls it once per service. So a digest override for one
service pinned aimock, pocketbase, dashboard, harness and
harness-workers to that service's image too.

Because of this, prod demos cannot be restored through the promote
workflow without breaking CPK-8652.

## Change

The first two commits make the change. The review-fix commits after them
harden input validation and widen prod verification to the held
services; each is described under **Review fix** below.

1. **`fix(showcase)`: the digest override applies only to the requested
service.** `resolve-promote-targets.sh` emits `digest_service` (the
requested SSOT name). `promote-fleet.sh` sends `--digest` only to that
service. All other closure members promote from their own staging
running digest, as they do without a digest. If a digest cannot be tied
to exactly one service in the plan, promote-fleet stops before it
promotes anything. That covers two cases: a multi-service plan without
`DIGEST_SERVICE`, and a `DIGEST_SERVICE` that is not in the plan. The
old single-service call shape (`DIGEST` with a one-service plan) still
works. (Later review fixes put every input through one guard and pass
the service after `--`; see below.)
2. **`feat(showcase)`: new optional `hold` input.** It takes a
comma-separated list of SSOT keys or dispatch_names, for example
`hold=harness,harness-workers`.
- The resolver walks the dependencies first. Then it removes each held
service from `services_csv`, `closure_csv` and `closure_plan`, so prod
keeps that service's current image.
- The resolver emits `held_csv` and lists the held services in the step
summary under **Held, unchanged**.
- The resolver rejects three cases loudly: an unknown name (so a typo
cannot promote the service you meant to hold), holding the service the
run promotes, and a hold that removes every service from `all`.
- `promote-fleet.sh` lists the held set in its summary (`HELD (n):
...`). As a second check, it promotes nothing if a held service is still
in the plan.

### Gates are kept, and now cover the held services

No gate is skipped or weakened. `verify-staging-precondition`, the
per-service `bin/railway` P1–P6 checks, `verify-prod`,
`compatibility-refresh`, the prod equivalence re-sweep and the lint-prod
pinned-ness gate all still run.

What changed in how they are fed and how inputs are checked (details in
the **Review fix** sections):
- **Prod verification scope (`verify_csv`).** promote-fleet emits
`verify_csv` = the succeeded set plus the held set (failed and
not-attempted services excluded). `verify-prod`, `compatibility-refresh`
and the equivalence re-sweep now read `verify_csv` instead of
`succeeded_csv`, so the held services are checked in prod on their
current image next to the promoted ones. `succeeded_csv` stays the
mutation set. With nothing held, `verify_csv` equals `succeeded_csv`, so
a run without `hold` verifies the same set as before.
- **`HELD_CSV` validation.** promote-fleet validates the whole
`HELD_CSV` value before parsing and refuses the run if a held service is
still in the plan.
- **Plain service-token validation.** Every service token that reaches
`preflight_scope` and the CLI (from `SERVICES_CSV`, `CLOSURE_PLAN`,
`HELD_CSV`, `DIGEST_SERVICE`) must be a known SSOT name of `[a-z0-9-]`
that does not start with `-`, checked by the shared input guard before
`preflight_scope` runs. `preflight_scope` then refuses a held service in
the plan, or a digest that cannot be scoped to exactly one planned
service.
- **Non-empty tier names.** Each `CLOSURE_PLAN` `tier:name` entry must
have a non-empty name, checked per entry before the names are joined.
- **Step summary.** The resolver summary lists the **Requested
service(s)** separately from the **Mutation plan** (the filtered closure
this run actually promotes), with held services under **Held,
unchanged**.

lint-prod still checks every prod service, including the held ones, for
an immutable `@sha256:` pin. With `hold=harness,harness-workers`, the
prod control plane used by the re-sweep and the compatibility refresh is
the current prod harness and workers.

## Red / green (real scripts, committed SSOT
`railway-envs.generated.json`, fake Railway CLI shim; no Railway calls)

### RED, `origin/main` 3f73c87

The resolver has no hold, so harness and harness-workers are always in
the closure:

```
### INPUT=langgraph-python HOLD=harness,harness-workers (HEAD 3f73c87)
exit=0
services_csv=showcase-langgraph-python
closure_csv=aimock,pocketbase,dashboard,harness,harness-workers,showcase-langgraph-python
closure_plan=0:aimock,0:pocketbase,1:dashboard,1:harness,1:harness-workers,2:showcase-langgraph-python
(no 'held' in step summary)

### INPUT=showcase-aimock HOLD= (HEAD 3f73c87)
closure_plan=0:aimock,0:pocketbase,1:dashboard,1:harness,1:harness-workers
```

promote-fleet sends the digest to all six services:

```
FAKE-RAILWAY ARGS: promote aimock --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
FAKE-RAILWAY ARGS: promote dashboard --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
FAKE-RAILWAY ARGS: promote harness --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
FAKE-RAILWAY ARGS: promote harness-workers --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
FAKE-RAILWAY ARGS: promote pocketbase --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
FAKE-RAILWAY ARGS: promote showcase-langgraph-python --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
```

bats before the fix: 50 ok, 14 not ok. The 14 failures are all new
tests: 9 in `resolve-promote-targets.bats` (CopilotKit#18–26) and 5 in
`promote-fleet.bats` (CopilotKit#60–64).

### GREEN, this branch, same invocations

```
### INPUT=langgraph-python HOLD=harness,harness-workers
exit=0
services_csv=showcase-langgraph-python
held_csv=harness,harness-workers
closure_csv=aimock,pocketbase,dashboard,showcase-langgraph-python
closure_plan=0:aimock,0:pocketbase,1:dashboard,2:showcase-langgraph-python

### INPUT=showcase-aimock HOLD=harness,harness-workers
closure_plan=0:aimock,0:pocketbase,1:dashboard

### INPUT=langgraph-python HOLD=harnes
::error::Cannot hold 'harnes': it does not match exactly one SSOT service (key or dispatch_name).
exit=1

### INPUT=langgraph-python HOLD=langgraph-python
::error::Cannot hold 'showcase-langgraph-python': it is the service this run promotes. Remove it from 'hold' or pick another service.
exit=1
```

Step summary:

```
**Held, unchanged** (`hold` input — NOT promoted; prod keeps its current image and the prod gates run against it):

- `harness`
- `harness-workers`
```

End to end: the resolver output (with `DIGEST` set) goes into
promote-fleet, which runs against the fake railway. Exit 0:

```
Attempted 4 service(s) from CLOSURE_PLAN (tier-ordered).
SUCCEEDED (4): aimock pocketbase dashboard showcase-langgraph-python
HELD (2): harness harness-workers
FAILED (0): (none)
railway invocations:
promote aimock --yes --non-interactive
promote dashboard --yes --non-interactive
promote pocketbase --yes --non-interactive
promote showcase-langgraph-python --yes --non-interactive --digest ghcr.io/copilotkit/x@sha256:deadbeef
```

Same plan without `DIGEST_SERVICE`: refused, 0 railway calls. Plan with
a held service added back in: refused, 0 railway calls.

### Review fix (aab5124): `hold` fails closed

Mark found that a multi-line `hold` value (`"harness,
harness-workers"`) held only `harness` and still promoted
`harness-workers`, with exit 0. The resolver now rejects any character
outside `[a-z0-9, -]`, including CR, LF and tab. It also rejects a held
service that is not in the closure (no silent no-op). All validation
runs before any output is written. 5 bats regressions were added; 4 of
them fail on d572327 and all pass now.

### Review fix (c2fa495): held services are verified; HELD_CSV fails
closed

- **Held services are now verified in prod.** promote-fleet emits
`verify_csv`: the succeeded set plus the held set, with failed and
not-attempted services excluded. `verify-prod`, `compatibility-refresh`
and the equivalence re-sweep now read `verify_csv`, so prod is checked
for the held services on their current image. `succeeded_csv` stays the
mutation set. Before: with `service=all` and
`hold=showcase-langgraph-python`, `succeeded_csv` had 41 services and no
langgraph-python. After: `verify_csv` has 42 and includes it.
- **`HELD_CSV` fails closed in promote-fleet.** The whole value is
validated with the same rule as the resolver: no CR, LF, tab or other
character, and each token must be a plain name. Before:
`HELD_CSV=$'svc-outside,\nsvc-h'` promoted `svc-h` with exit 0. After:
refused, with 0 railway calls.

### Review fix (3d88a9a): one input guard, and the service is passed
after `--`

Mark's repro: `SERVICES_CSV=--yes HELD_CSV=shell` (and
`CLOSURE_PLAN=2:--yes`) made the fleet call `promote --yes --yes
--non-interactive`. The real CLI's OptionParser read the service as a
flag, so `options[:service]` was nil. It promoted the **whole fleet**,
including the held `shell`, and the wrapper exited 0 and reported shell
as HELD.

- New `showcase/scripts/promote-input-guard.sh`, sourced by both the
resolver and promote-fleet, is the one input guard. Every value is
validated whole, before parsing, and the run stops before any CLI call.
A service list must be `[a-z0-9-]` SSOT names joined by commas: no
CR/LF/tab/space, no empty entry, no leading `-`. A digest may contain
only image-ref characters and must not start with `-`. The guard covers
resolver `service`/`hold`/`digest` and fleet `SERVICES_CSV`,
`CLOSURE_PLAN` (the name after `N:`), `HELD_CSV`, `DIGEST_SERVICE` and
`DIGEST`.
- promote-fleet now calls `promote --yes --non-interactive [--digest D]
-- <svc>`. I checked offline against the real CLI that `--` keeps the
service positional; `-- --yes` is rejected as an unknown service.
- Behavior change: stray commas and whitespace in
`SERVICES_CSV`/`CLOSURE_PLAN` (previously skipped or trimmed) and spaces
in `hold` now fail closed. The four old tolerance tests were rewritten
to assert that.

Before/after on the real `bin/railway` PromoteCommand with an
intercepted transport (fake GQL/GHCR, no network):

```
c2fa495  SERVICES_CSV=--yes HELD_CSV=shell
  CLI argv: ["--yes", "--yes", "--non-interactive"]
  CLI parsed service: nil (nil = WHOLE-FLEET promote)
  CLI pinned prod services: prod-aimock prod-harness prod-shell
  SUCCEEDED (1): --yes / HELD (1): shell / exit=0
3d88a9a  SERVICES_CSV=--yes HELD_CSV=shell
  ::error::promote-fleet: SERVICES_CSV entry '--yes' starts with '-' and would be read as a CLI option; refusing to promote anything.
  0 CLI calls, exit=1
```

`CLOSURE_PLAN=2:--yes`, `--foo` and `-x` behave the same way: refused, 0
CLI calls, exit 1. A normal plan, `CLOSURE_PLAN=0:aimock,2:shell` with
`DIGEST_SERVICE=shell` and `HELD_CSV=harness`, pins exactly
`prod-aimock` and `prod-shell`. The digest goes only to shell.

### Review fix (a12ca33): empty names in closure plan entries

Before this fix, `CLOSURE_PLAN='0:,2:showcase-ag2'` passed the tier
check. The empty name vanished when the names were joined, and the leaf
promoted with exit 0. Each `tier:name` entry's name is now checked by
the guard on its own, before joining. Leading (`0:,2:x`), repeated
(`0:x,1:,2:y`) and trailing (`...,2:`) empty names are refused with 0
CLI calls. Before this fix, `0:,2:svc-a` reached the CLI in bats, and
`0:,2:showcase-ag2` did the same against the real CLI.

### Review fix (10d384d): step summary names the actual mutation plan

The resolver step summary used to say the leaf was "what actually
promotes now" and called the tiered closure equivalence-only. In fact
the promote job runs promote-fleet from `closure_plan`. For
`service=agno` with `hold=harness,harness-workers` it promotes `aimock`,
`pocketbase`, `dashboard` and `showcase-agno`. The summary now lists
**Requested service(s)** separately and labels the filtered closure as
the **Mutation plan** (what this run actually promotes in prod). Held
services are still listed as **Held, unchanged**. A bats assertion
covers this.

## Tests and lint

- `bats resolve-promote-targets.bats promote-fleet.bats`: 88/88 ok. The
full `showcase/scripts/__tests__/` directory: 212/212 ok. Run locally on
macOS bash 3.2. CI runs the same suite on ubuntu bash 5
(`showcase_validate.yml`).
- The intermediate commit (digest scope only) also passes on its own:
55/55.
- `shellcheck` 0.11.0: clean on both scripts.
- `oxfmt --check` on the workflow: clean.
- `vitest registry-validation-workflows.test.ts
sync-promote-service-options.test.ts`: 29/29.
`sync-promote-service-options.ts` regenerates with no diff.
- `actionlint`: one finding, the self-repository `uses: $/...` call.
This is already on `main` and documented in the workflow
(rhysd/actionlint#760). Nothing new.

## Risks

- **Version skew is the intended effect.** A promoted service runs in
prod against the held harness/workers (and anything else held) at their
current images. Nothing proves before the pin that the new service image
works with the old harness. The gates after the promote (per-service
prod probe, equivalence re-sweep, compatibility refresh) run against the
held images and red the run if the pair is broken. But by then the
service is already pinned, so recovery means rolling that service back.
- **Equivalence re-sweep across harness versions.** The re-sweep
compares prod rows (from the held prod harness) to staging rows (from
staging's harness). If the two harness versions probe differently, the
gate can fail even when the service is fine. It can also miss a real
regression. The gate is reported, not suppressed.
- **Holding a dependency of the requested service is allowed.** For
example, `hold=aimock` while promoting an integration that uses aimock.
That is the operator's decision, and the step summary shows it.
- **Behavior change for direct `promote-fleet.sh` callers.** A caller
that sets `DIGEST` on a multi-service plan without `DIGEST_SERVICE` is
now refused instead of pinning every service to one image. The workflow
always sets `DIGEST_SERVICE`.
- **Not run against real infrastructure.** By design, this PR dispatched
no workflow and made no Railway call. The first real use is a
`workflow_dispatch` with `hold=harness,harness-workers`.
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