Skip to content

chore: deprecate the standalone V2 package - #344

Open
jerome-benoit wants to merge 7 commits into
mainfrom
chore/deprecate-standalone-v2-package
Open

jerome-benoit wants to merge 7 commits into
mainfrom
chore/deprecate-standalone-v2-package

Conversation

@jerome-benoit

@jerome-benoit jerome-benoit commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Description

@jerome-benoit/sap-ai-provider-v2 duplicates the /v2 subpath of the main package, which every 5.x release of that package exports: 5.0.0 lists ././v2/./v4 in exports, 5.0.2 and later add ./v3, while 4.9.1 — the last 4.x release — lists only .. Publishing the standalone name doubles the release surface for a facade that already has a supported home. This PR deprecates it properly: the package stops being published, the versions already on the registry get a deprecation message, and CI guards the freeze.

Publication freeze

  • .github/workflows/npm-publish-packages.yml: the publish-npm-v2 job and the build:v2 step are removed; prepublishOnly loses its AI_SDK_VERSION=v2 branch.
  • tsup.config.v2.ts, scripts/prepare-v2-package.ts and the build:v2, build:v2:watch, prepare:v2, check-build:v2 scripts are deleted. npm run build already emits index-v2.* and npm run check-build already verifies that artifact family, so the standalone build path was a duplicate.
  • scripts/check-build-artifacts.ts drops the v2 artifact family; scripts/check-package-exports.ts drops the standalone-manifest branch.

Deprecation of the published versions

  • New scripts/v2-package-deprecation.ts, its CLI entry scripts/v2-package-deprecation-cli.ts and co-located tests:
    • npm run check-v2-package — read-only; the CI guard. Stops when the freeze cannot be attested: a version above the frozen 5.1.2, a latest dist-tag that moved away from that version or that the versions table does not list, another dist-tag pointing outside that table, a version key npm could not have published (5.01.2, 5.1.2-01, build metadata, an over-long string), a version record whose own name or version does not match its key, or a document that cannot be read at all — including a registry that answers 404, which is named as such because it proves neither a removal nor a held freeze. It prints deprecation coverage without enforcing it: a version without the message never fails this command.
    • npm run verify-v2-package — read-only; the coverage check. Fails while a published version lacks the canonical deprecation message, so it stays out of CI until the one-time write below has run: the registry holds 53 versions today and 0 carry the message.
    • npm run deprecate-v2-package — dry run by default; -- --apply writes through npm. The package spec stops at the frozen version, so the versions npm selects from its own registry read cannot go past the freeze; npm_execpath must be an absolute path to an existing npm-cli.js; and --apply is refused outside npm run deprecate-v2-package. The command pins --dry-run=false, because an inherited dry-run setting makes npm skip the write and still exit zero. It never re-reads the registry, so verify is what confirms coverage.
  • npm run check-v2-package runs in the PR validation job and in the release build job, so a re-published -v2 version, a moved latest tag or an unreadable registry document stops CI. That guard detects rather than prevents — step 1 below is the prevention — and it reads the document through npm's CDN, which caches it for up to five minutes (cache-control: public, max-age=300), so a registry change made inside that window can stay invisible; ARCHITECTURE.md records both limits.
  • No npm token is added to CI on purpose. The registry write is one-time, so it stays a documented maintainer operation and this repository keeps its OIDC-only publishing posture. ARCHITECTURE.md documents the command sequence.

Documentation

/v2 is presented as the only supported V2 facade in README.md, API_REFERENCE.md, ARCHITECTURE.md, CONTRIBUTING.md, ENVIRONMENT_SETUP.md, MIGRATION_GUIDE.md, TROUBLESHOOTING.md, the PR template and the agent instructions. The obsolete prepare:v2 troubleshooting entry and the sequential-build description are removed. The standalone-package migration steps uninstall the frozen package and install the main package without an ai range, because pinning ai@^5 would downgrade an AI SDK 6 consumer; they refer to the per-major installation table instead.

Hardening after review

The first review round found no blocker; these are its follow-ups, each verified against the live registry and the existing suites:

  • Registry document is now attested, not just read: per-version name/version identity, dist-tags confined to the versions table, version keys restricted to the grammar npm can publish, and prerelease ordering done on exact digit strings instead of floats. The live abbreviated document satisfies all of it (allHaveName/allHaveVersion true for 53/53, both dist-tag targets present), so check still passes on the real registry.
  • A 404 from the canonical registry gets its own diagnostic instead of a generic read failure; the gate still exits 1, because publication must stay blocked while the freeze cannot be attested.
  • Two command entries no longer decide by comparing process.argv with the module URL: scripts/check-build-artifacts-cli.ts and scripts/check-lockfile-release-age-cli.mjs always run, the libraries run nothing on import, and a test executes exactly what package.json points at, so repointing a script at a file that does not run stops failing silently. This is the mode commit 57edeca documented for the advisory gate; scripts/check-toc.ts and scripts/check-markdown-links.ts keep the old guard and are out of scope here (lint scope, no publication path).
  • The deprecation message no longer claims "same releases": of the 53 standalone versions, 4.1.2-rc.1, 4.1.2-rc.2 and 4.4.7 do not exist under the main name and only main-package 5.x exposes /v2. It now says the /v2 facade ships with the main package. Nothing was written to the registry yet, so this cost nothing to correct.
  • One normative sentence in ARCHITECTURE.md now owns when verify joins CI; .cursor/rules/build-and-publish.mdc and openspec/config.yaml refer to it instead of stating an invariant that the one-time write would invalidate.

Type of Change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

No published package changes runtime behaviour. Existing installations of the frozen -v2 versions keep working; only new releases of that package name stop.

Checklist

  • I have run the local candidate checks: npm run check-lockfile-release-age && npm run check-dependency-audit && npm run type-check && npm run test:node && npm run test:edge && npm run prettier-check && npm run lint
  • I have run npm run build && npm run check-build && npm run check-v2-package
  • I have updated documentation (if applicable)
  • I have added tests for new functionality (if applicable)
  • My changes follow the existing code style
  • I understand the trusted lockfile gate runs separately on GitHub and cannot be replaced by the local candidate check

Both candidate gates passed on head b74563f: 187 lockfile artifacts verified, no advisory left unexplained, 1874 Node tests, 1113 Edge tests, Prettier, Markdown lint with ToC and Mermaid checks, ESLint, and a build verified for artifacts, declaration routing and the standalone freeze.

Related Issues

Additional Notes

Measured against the live registry on this branch:

$ npm run check-v2-package
Freeze holds: 53 published versions, none above 5.1.2.
0 carry the canonical deprecation message; 53 miss it or carry a different one.
Run npm run deprecate-v2-package -- --apply to store the message.

$ npm run deprecate-v2-package
Dry run: npm deprecate targets every version matching @jerome-benoit/sap-ai-provider-v2@<=5.1.2.
Registry snapshot: 53 of 53 published versions lack the canonical deprecation message.

$ npm run verify-v2-package   # exits 1
Canonical deprecation message missing on: 4.1.2-rc.1, …, 5.1.2   # all 53 versions are named

$ npx tsx scripts/v2-package-deprecation-cli.ts deprecate --apply   # exits 1, npm never started
Run npm run deprecate-v2-package -- --apply to write the message.

These operator steps remain after merge, in this order.

  1. Remove the npm trusted-publisher configuration from the frozen package. The registry still records it for the published head version, so a workflow in this repository that matches that configuration can still write under the name:

    curl -sS https://registry.npmjs.org/@jerome-benoit%2Fsap-ai-provider-v2/5.1.2 | jq '._npmUser'
    # {"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com",
    #  "trustedPublisher":{"id":"github","oidcConfigId":"00be9ade-c1d2-4e46-b1e8-68aaa5e8ae72"}}

    Clearing it happens on the npm side (package → Trusted publishing) and must precede any claim that the freeze is enforced from the registry alone.

  2. Perform the one-time write from an authenticated npm CLI session:

    npm run deprecate-v2-package             # dry run: the npm version range, the message, the pending count
    npm run deprecate-v2-package -- --apply  # writes it; npm's exit status is the only confirmation this command gives
    npm run verify-v2-package                # coverage check; allow up to five minutes for the CDN-cached document to refresh
  3. Add npm run verify-v2-package beside npm run check-v2-package in the validation job of .github/workflows/check-pr.yaml — keep that step's existing if: runner.os == 'Linux', or three operating systems would triple the registry reads per pull request — and in the build job of .github/workflows/npm-publish-packages.yml. Then retire the normative sentence in ARCHITECTURE.md (Build Process) and update the two files that refer to it: .github/copilot-instructions.md and openspec/config.yaml.

build:v2 and check-build:v2 are gone from the checklist, so the PR-template line now reads npm run build && npm run check-build && npm run check-v2-package.

- Stop publishing `@jerome-benoit/sap-ai-provider-v2`: drop its publish job, `tsup.config.v2.ts`, `scripts/prepare-v2-package.ts`, the `AI_SDK_VERSION=v2` `prepublishOnly` branch, and the `build:v2`, `build:v2:watch`, `prepare:v2` and `check-build:v2` scripts.
- Add `scripts/v2-package-deprecation.ts`: a read-only registry freeze check (`check`), a deprecation-coverage verification (`verify`), and the one-time authenticated write (`deprecate --apply`).
- Run `npm run check-v2-package` in the PR validation job and in the release build job, so a re-published `-v2` version or a lifted freeze fails CI.
- Document `/v2` as the only supported V2 facade across README, API_REFERENCE, ARCHITECTURE, CONTRIBUTING, ENVIRONMENT_SETUP, MIGRATION_GUIDE, TROUBLESHOOTING, the PR template and the agent instructions.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T21:12:09.019585Z b74563f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread scripts/v2-package-deprecation.ts Fixed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34b90013f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/v2-package-deprecation-cli.ts Resolved
CodeQL flagged the string-literal replacement as replacing only the first
occurrence of the separator. Splitting and joining encodes every separator
and yields the identical registry path for valid npm package names, so the
freeze, coverage, and dry-run gates keep the same behaviour.
- `--apply` pins `--dry-run=false`: an inherited `dry-run` setting makes npm
  skip the write and still exit zero, so the gate would claim a write that
  never happened. CLI flags outrank `npm_config_dry_run` and any `.npmrc`.
- Registry-supplied `latest` and unorderable version keys print escaped, so a
  registry value cannot forge a `Freeze holds` line in CI logs.
- Argument parsing and the npm invocation moved to the library, which imports
  without side effects; the CLI entry stays thin and always executes.
- Tests run the real entry in child processes against a stubbed registry
  transport, count the served reads, and strip every `npm_` spelling plus
  `NODE_OPTIONS` from the child environment.
- Docs and agent rules still described two published packages, the removed
  `build:v2`/`prepare:v2` scripts, a deprecation message already stored on the
  published versions, and a manifest rewrite only the release workflow does.
- `npm deprecate` with the bare package name targets every version of npm's
  own uncached registry read, so a version published after the gate snapshot
  would receive a message naming 5.1.2 as the last release; the spec now
  stops at the frozen version.
- `npm_execpath` must be an absolute path to an existing `npm-cli.js`, and
  `--apply` runs only from its own npm lifecycle script, so a direct
  invocation cannot start another executable with the npm credentials of the
  caller.
- The dry run separates the npm target range from what the registry snapshot
  still misses, and exit zero no longer claims more than that npm reported no
  error.
- Tests drop inherited `TSX_*` variables, because a stray `TSX_TSCONFIG_PATH`
  made the whole suite fail before any stubbed registry read.
- `MIGRATION_GUIDE.md` uninstalls the frozen package and pins no `ai` range;
  `ARCHITECTURE.md` records the five-minute CDN window of the guard.
Reading the abbreviated packument was not enough to attest a freeze. A version
key such as 5.01.2, 5.1.2-01 or 5.1.2+build is greater than 5.1.2 under
semver.gtr and is rejected by no guard today, a version record may disagree
with the key that holds it, and a dist-tag may name a version the versions
table does not list.

- Restrict version keys to the grammar npm can publish, and compare prerelease
  identifiers on exact digit strings instead of through Number().
- Require each version record to carry the package name and the version of its
  own key when that field is present.
- Require every dist-tag value, latest included, to be a key of the versions
  table.
- Name a 404 from the canonical registry origin instead of reporting a generic
  read failure; publication stays blocked while the freeze cannot be attested.
- Drop "same releases" from the deprecation message: 4.1.2-rc.1, 4.1.2-rc.2 and
  4.4.7 exist only under the standalone name, and only main-package 5.x exposes
  the /v2 facade. No version carries a message yet, so nothing written changes.
The artifact checker and the release-age gate decided whether to run from
process.argv[1] resolved against their own module URL. Pointing a published npm
script at either library file made it exit zero without checking anything, the
silent failure commit 57edeca removed from the advisory gate.

- Add scripts/check-build-artifacts-cli.ts and scripts/check-lockfile-release-age-cli.mjs,
  which always run; both libraries now export their checks and run nothing on
  import, and package.json points at the entries.
- Execute the command each manifest script declares, so repointing a script at a
  file that runs nothing fails a test instead of CI: the main and V4 artifact
  families, an absent artifact, an unknown family, and the release-age usage path.
- Lint scripts/*.mjs with the same override as the release-age library, now that
  a second .mjs holds a command entry.
The freeze rules were restated in six files, so a later change could keep one
copy true while another went stale, and two entries enumerated the failure
conditions with an incomplete list.

- ARCHITECTURE.md (Build Process) owns when npm run verify-v2-package joins
  continuous integration; .cursor/rules/build-and-publish.mdc and
  openspec/config.yaml now refer to that sentence instead of repeating an
  invariant the one-time write invalidates.
- Complete the guard description in ARCHITECTURE.md and
  .github/copilot-instructions.md: dist-tags outside the versions table,
  incoherent version records, unreadable documents and a registry that answers
  404 were checked but not documented.
- Say "the main package and the frozen standalone package" where a document said
  "both packages", and retitle the V2 facade section to match its anchor.
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.

2 participants