Skip to content

spec(AST-040): upgrade works on its project from any folder, and reports a CLI older than Core - #7543

Merged
josephfarina merged 5 commits into
mainfrom
josephfarina/upgrade-project-scope-spec
Oct 20, 2026
Merged

josephfarina merged 5 commits into
mainfrom
josephfarina/upgrade-project-scope-spec

Conversation

@josephfarina

@josephfarina josephfarina commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Exact decision needed

How astryx upgrade behaves when it runs in a folder other than the project root, and what it reports when the running CLI is older than the installed Core:

  1. Which project an upgrade works on, and where the search for it stops.
  2. Where a --path the caller names is read from, and what bounds it.
  3. Which installed Core a workspace member migrates to.
  4. What the file paths in the machine-readable result are relative to.
  5. What an upgrade reports when the installed Core is newer than the running CLI.

Existing authority searched

  • spec:AST-040 (current) owns what an operation may modify in an existing consumer file and how modified, blocked and declined files are reported (FR7). FR2 confines an operation to its operation root, but the record does not say which folder that is when upgrade runs below the project root. It also does not say which installed Core is the target, what result paths are relative to, or what happens when the CLI has no codemods for the installed Core. This PR amends it.
  • architecture:cli-surface (current) confines every write (INV10) without naming the root, and owns how agent docs render (INV13), not where upgrade runs.
  • spec:AST-048 (current) FR15 defines a folder's workspace root. FR9 reuses it rather than restating it.
  • spec:AST-017 (current) FR13 makes an optional result field a compatible change. FR13 here adds one.
  • Open pull requests: no other open specification pull request touches spec:AST-040. spec(cli-surface): agent docs reach every agent from the project's own files #7539, a draft amendment to architecture:cli-surface, sets where init writes agent docs. It finds init's project root by the same declaration, with the same version-control and home-folder stops, and differs in two ways: it does not count workspace members, and with no declaring folder it falls back to the nearest package.json. An upgrade falls back to the folder it runs in. The two rules govern different commands and do not contradict. Whether init should adopt the member rule is a separate decision for that draft.

Decision

Amends spec:AST-040:

  • The Intent names the upgrade claims, and a non-goal leaves other commands' project lookups to their owners.
  • FR9–FR13 are added.
  • Platform support adds the workspaces and install layouts of npm, pnpm, Yarn and Bun.
  • Verification gains one row per new requirement.

FR9 — An upgrade works on its project. astryx upgrade MUST operate on the project of the folder it runs in: the nearest folder at or above that folder whose package.json declares an Astryx package, or that its workspace lists as a member when the workspace root's package.json declares one. A package.json declares an Astryx package when any of its dependency fields, peer dependencies included, names an @astryxdesign/* package or a legacy @xds/* one. A folder's workspace root is the one spec:AST-048 FR15 finds from it, and the workspace lists the folder when a pattern in the root package.json workspaces field or in pnpm-workspace.yaml packages matches the folder and no exclusion pattern removes it. A folder that installs Core but qualifies neither way is not a project: an upgrade run there works on the project above it, if any. The search MUST NOT continue past a folder that holds version-control metadata, and MUST end at the home folder without counting it as a project or as a workspace root. The project root is the operation root (FR2): the upgrade reads the project's configuration, agent docs, and protection sources (FR3, FR4) there. When no folder qualifies, the folder the command runs in is the operation root.

FR10 — A named source folder is read where the command runs. By default, an upgrade MUST scan the src folder of the operation root. A source folder the caller names MUST be resolved from the folder the command runs in, and MUST be inside the operation root; one outside it fails with ERR_PATH_TRAVERSAL before any write.

FR11 — A workspace member migrates to the Core its workspace installs. The version an upgrade migrates to MUST be that of the Core (@astryxdesign/core, or the legacy @xds/core) the project installs: in the node_modules of the project root; for a member its workspace lists, in the nearest node_modules from the project root up to the workspace root; and for a project installed without node_modules, the copy its package manager resolves for it. A Core above a project that no workspace lists MUST NOT count. When no folder qualifies under FR9, the target is the Core in the node_modules of the folder the command runs in. With no installed Core, the upgrade fails with ERR_VERSION_DETECT before any write.

FR12 — The result names files from where the command runs. The machine-readable result of an upgrade MUST name its modified, protected, and declined files (FR7), the files its errors name, its agent-doc files, and the files of its copied-composition summary by paths relative to the folder the command runs in, so each resolves from there. When the command runs at the operation root, the copied-composition summary instead names its files relative to the source folder the upgrade scanned. When the operation root is another folder, the human-readable output MUST name it.

FR13 — A CLI older than the installed Core reports an incomplete upgrade. When the installed @astryxdesign/core is newer than both the running CLI and the version the upgrade starts from, the upgrade MUST run the codemods the running CLI has for the range, and its human-readable output MUST report the upgrade as incomplete and MUST NOT say the code is up to date. The machine-readable result MUST carry the optional cliBehindCore field, present only in this case, with the running CLI's version and one command that finishes the upgrade with the CLI release matching the installed Core. That command MUST work from any folder it is run in, upgrading the same project; it MUST repeat the run's options, MUST name the source folder the run scanned, and MUST quote each argument for the shell it targets. The human-readable output MUST print the command on a line of its own, and MUST name that shell unless it is a POSIX shell. This case does not change the exit status, or what complete and errorCode report under FR6.

Rejected alternatives

  • Checking a Core above the project against the version range the project declares. Overrides, resolutions, hoisting and peer-only declarations decide which copy a workspace member loads, so the declared range can disagree with the copy its code runs on. Reading ranges also needs a complete range parser. Workspace membership answers the question without reading versions.
  • Treating the nearest package.json as the project. A home folder or a tool folder with a package.json would become the project of every folder below it, and an upgrade would scan and rewrite files that belong to other projects.
  • Refusing when the CLI is older than the installed Core. Exiting nonzero changes released exit behavior, which spec:AST-017 treats as an incompatible change.

Claim scope and non-goals

  • FR9–FR13 govern astryx upgrade only. Where other commands look for the project, init included, stays with their owners.
  • FR11 sets which installed copy is the target. It does not set how versions compare or which codemods a range selects.
  • FR12 sets what result paths are relative to. It adds no field, and it does not set the frame of human-readable lines beyond naming the operation root.
  • FR13 sets what the result reports and what the printed command must do. It does not set the wording of the human-readable lines, which one-off runner the command uses, how the command reaches the project from another folder, or which shell it targets on each platform.

Evidence and implementation relationship

  • Below the project root, an upgrade found no Core or scanned the wrong folder. An installed Core alone does not make a folder a project, so a folder that installs Core without declaring Astryx is upgraded as part of the project above it, against that project's Core. Under a home folder with a package.json, the nearest package.json made the home folder the project, and an upgrade rewrote files across unrelated projects. Membership keeps hoisted workspaces working: members under overrides, resolutions, hoisted pnpm installs, peer-only declarations, and declared ranges the hoisted copy falls outside all find the Core their workspace installs, while a nested project outside any workspace finds only its own.
  • A CLI change that implements FR9–FR12 is in review separately.
  • A CLI change that adds cliBehindCore is also in review, and implements FR13. Its command first changes to the folder the run used, so it works pasted from any folder. It targets a POSIX shell, or PowerShell on Windows, where the warning names PowerShell.

Writing rubric results

  • R1 narration: none. FR9–FR13 state what an upgrade does, in the present tense.
  • R2 research in the record: none. The workspace layouts appear only as verification states.
  • R3 evidence naming a change: none. The new verification rows name the kind of evidence and its failure signal.
  • R4 rejected alternatives over one line or outside a decision: none in the record. They are listed in this description.
  • R5 pull request or issue references remaining: none.
  • R6 ruled open questions still listing options: none. Open questions stay "None."

Scope

  • This PR contains specification records only.
  • It records observable behavior and preserves equivalent internal implementations.
  • Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract. The record names only public inputs and outputs: package.json fields, pnpm-workspace.yaml, the cliBehindCore result field, and error codes.
  • Verification states the evidence layer and failure signal without prescribing CI job/workflow topology.
  • It records one intentional durable decision, not a rescue for a separable tagalong. That decision is what an upgrade works on and what it reports when it cannot finish.
  • The canonical knowledge owner, affected current claims, and overlapping open work are named; any ownership collision is resolved or called out for human decision.
  • Adjacent API, visual, accessibility, composition, and implementation facts remain outside scope unless this exact decision depends on them.
  • Public text and artifacts contain no internal Meta context.

Validation

  • pnpm check:knowledge
  • Prettier
  • git diff --check

…rts a CLI older than Core

Amend the record that owns what an upgrade may modify and how it reports
files:

- FR9: an upgrade works on the project of the folder it runs in, the
  nearest folder whose package.json declares an Astryx package or that
  its workspace lists as a member; the search stops at version-control
  metadata and never counts the home folder.
- FR10: a named source folder is read from the folder the command runs
  in and stays inside the operation root.
- FR11: a workspace member migrates to the Core its workspace installs.
- FR12: result paths are relative to the folder the command runs in.
- FR13: a CLI older than the installed Core runs the codemods it has,
  reports the upgrade as incomplete, and names a command that finishes it
  with the matching CLI release.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 14, 2026
@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 20, 2026 4:21pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Oct 20, 2026, 4:13 PM UTC

…the shell it targets

FR13: the command that finishes an upgrade with the CLI release matching
the installed Core works from any folder it is run in, upgrading the same
project. It repeats the run's options, names the source folder the run
scanned, and quotes each argument for the shell it targets. The
human-readable output names that shell unless it is a POSIX shell. The
verification row runs the printed command inside the project, above it,
and in an unrelated folder.
…pied-composition paths resolve from where upgrade runs

- FR9: a folder that installs Core but neither declares an Astryx package
  nor is a listed member is not a project; an upgrade run there works on
  the project above it, if any.
- FR12: from a folder below the operation root, the copied-composition
  summary also names its files relative to the folder the command runs
  in. At the operation root it names them relative to the scanned source
  folder.
@josephfarina
josephfarina marked this pull request as ready for review October 20, 2026 16:13
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec ac085eb

@github-actions github-actions Bot added spec-auto-merge Auto-merge was enabled by the spec owner gate and removed needs:spec-owner-review Current knowledge records await owner approval labels Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@josephfarina
josephfarina merged commit 5a96bf9 into main Oct 20, 2026
48 of 49 checks passed
@github-actions
github-actions Bot deleted the josephfarina/upgrade-project-scope-spec branch October 21, 2026 06:22

This branch was successfully deployed

1 active deployment
Preview — ac085eb5 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. spec-auto-merge Auto-merge was enabled by the spec owner gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant