Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report🔎 Preview ·
|
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for fixing nested component copies. Two boundaries still block this head:
- A nested symlink already present under the destination is followed, so
swizzle Tablecan write throughTable/pluginsoutside the requested output tree. Please reject symlinks in every destination path segment before any write and add a regression for that case. - Integration components can share one source directory. Recursing from that directory means swizzling one component also copies sibling components and shared files (for example,
Alphaalso copiesBeta.tsx). Please derive the selected component's exact owned file boundary rather than treating the containing directory as the component root, with a multi-component integration regression.
The focused and current-main synthetic-merge tests pass, but they do not cover these two cases.
Automated review posted in error while an unresolved ownership decision is still under review.
|
@cixzhang Could you review the updated head, 65b265b?
Validation: 42 focused tests pass, as do CLI strict typechecking, strict lint, repository checks, and the full package build. The full test suite has 10,379 passes and two filename-case failures whose behaviors also reproduce on the untouched prior head. CI is running on this update. |
There was a problem hiding this comment.
Thanks for the clean recursive fix — copying Table's nested plugins, handling import depth, reporting nested paths, and rejecting destination symlinks (including dangling links, even with --overwrite) all look well targeted, and keeping integration copies flat avoids inventing a new ownership policy.
One destination shape still needs handling before this is ready:
- In
packages/cli/api/swizzle/copy/copy.mjs, the preflight checks each destination segment only for symlinks. If an intermediate path such asout/Table/pluginsalready exists as a regular file, the check itself throws a rawENOTDIRerror with an absolute path instead of a stable Astryx error. Worse, if a planned file destination such asout/Table/plugins/nested.tsalready exists as a directory and--overwriteis used, earlier files are written first and the copy then fails with a rawEISDIR, leaving a partial copy in the consumer's tree.
Please extend the preflight to validate destination shape before any write — existing intermediate segments must be directories and existing leaf targets must not be directories, regardless of --overwrite — returning a stable error code, with regression tests for both shapes asserting that no file is written. After that, the rest of the change looks ready.
[Automated review]
humbertovirtudes
left a comment
There was a problem hiding this comment.
Reviewed exact head 65b265b0, including the copy preflight, recursive import rewriting, receipts, and tests. Requesting changes.
packages/cli/api/swizzle/copy/copy.mjs:223-240,340-377 does not preflight destination type collisions. If a late destination such as Table/types.ts is already a directory, earlier sorted files are overwritten before writeFileSync() fails with EISDIR. That violates the stated all-paths-before-write guarantee and can leave a partially modified destination. Please validate every intermediate segment and final target type before any mkdir or write, with a regression proving no earlier file changes when a late destination has the wrong type.
Also make integration receipt ordering deterministic at copy.mjs:335-339; the current test requires exact order while production returns raw readdirSync() order.
This head currently conflicts with main. It also overlaps open #6621 in copy.mjs and swizzle.doc.mjs, and #6507 in swizzle.doc.mjs. Rebase and reconcile those changes rather than resolving the files wholesale.
65b265b to
deaaa1c
Compare
|
@humbertovirtudes Thanks. Addressed on Destination type collisions.
I used Regression ( Receipt ordering. The flat integration list is now sorted like the core walk, so the exact-order assertion in Rebase and reconciliation
Validation
|
There was a problem hiding this comment.
Thanks for the thorough fix — swizzle now copies nested core source completely (Table's plugins included), rewrites imports by depth, reports nested paths in the receipt, and keeps integration copies flat without inventing a new ownership policy.
The destination-shape gap from the previous round is addressed: existing intermediate segments must be directories and existing leaf targets must not be directories, checked before any write regardless of --overwrite, with a stable ERR_WRITE_FAILED naming the project-relative path. The new regression tests assert both shapes (and the symlink matrix) leave the destination unchanged, and receipt ordering is now deterministic for both core and integration copies.
One note: I could not independently rerun the test suite in this environment, so the passing focused tests, typecheck, lint, and build rest on your reported results, which are consistent with the code and tests as written. With that, this looks ready to approve.
[Automated review]
deaaa1c to
5447ece
Compare
|
Rebased onto current The previous fixes remain intact: all destination segments and leaf types are checked before any write, Validation on this revision: 54 focused swizzle tests, CLI strict typecheck, @humbertovirtudes Please re-review the rebased head. #6621 and #6507 remain separate open PRs; their unmerged behavior has not been folded into this change. |
There was a problem hiding this comment.
Thanks for the thorough fix — swizzle now copies nested core source completely (Table's plugins included), rewrites imports by depth, reports nested paths in the receipt, keeps integration copies flat, and rejects destination symlinks and wrong-kind destination paths before any write. The focused swizzle suites also pass when rerun here.
One thing still needs handling before this is ready:
- The recursive walk now also copies
__tests__/directories, which the old flat copy never reached. For example,swizzle Buttoncopies 7 files, 5 of them__tests__/Button.a11y.*test-harness files, andswizzle Tableincludes__tests__/TableScroll.a11y.chromium.spec.ts. Those files import@playwright/testand@astryxdesign/a11y-spec, which is a private, unpublished internal package, so consumers get copied files they cannot resolve. The collector only excludes files by basename (.test.,.doc.), which these harness files do not match.
Please skip test-only directories (__tests__, __snapshots__) in the recursive collector and add a regression asserting no __tests__/ path is copied or reported. After that, the rest of the change looks ready.
[Automated review]
|
Thanks for sticking with this one, and sorry it has taken four attempts across three PRs to get here. This is the right fix and it reads well — the per-segment symlink checks, the depth-aware import rewriting, and driving copy, preflight and receipt from one sorted file set. One thing to remove and then I will stamp it: the recursive walk now picks up Worth updating the comment above It is also 526 commits behind main, so it will need a rebase. Ping me when it is up and I will approve. |
Core component directories are walked recursively so nested source (e.g. Table/plugins/*) is copied, reported and preflighted from one sorted file set. Escaping relative imports are rewritten by depth. Every destination segment is checked before any write: no symlinks, existing directory segments must be directories and existing file targets regular files, regardless of --overwrite. Integration copies keep their flat boundary.
The recursive walk entered __tests__/ and __snapshots__/, which the old flat copy never reached. Their harness files do not all match the .test. basename filter (e.g. Button.a11y.harnesses.tsx, TableScroll.a11y.chromium.spec.ts) and import dev-only packages such as the unpublished @astryxdesign/a11y-spec, so swizzle Button copied 5 files a consumer cannot resolve. The collector now skips those directories at any depth; tests assert nothing under them is copied or reported, for real components and a nested fixture.
5447ece to
89f332e
Compare
|
@josephfarina Thanks! Done on
Rebase note: main's rollback from #6621 met the recursive copy here. The copy loop now creates nested directories inside the guarded write and records the ones it created, so a part-way failure removes them too. Otherwise Validation: full CLI suite (394 files, 6301 tests), |
There was a problem hiding this comment.
Thanks — the recursive copy, the depth-aware import rewriting and the up-front destination checks look right, and the __tests__/__snapshots__ skip works for every Core component, but this needs one fix and one maintainer decision before it can be approved. swizzle Markdown still copies plugins/headingLinks.a11y.chromium.spec.ts, which imports @playwright/test and the unpublished @astryxdesign/a11y-spec, so please also skip *.spec.ts/*.spec.tsx harness files in the recursive walk and add Markdown to the test-only regression. Refusing a destination symlink that stays inside the project (for example components → src/components) changes behavior the released CLI allows, and no current spec covers it, so approval also needs a maintainer to decide whether that setup is supported and to name the spec that governs it; that settles whether this can ship as a patch fix. The earlier change request from humbertovirtudes, which this head addresses, also needs a re-review or dismissal.
[Automated review]
| if (entry.isDirectory()) { | ||
| if (TEST_ONLY_DIRS.has(entry.name)) continue; | ||
| files.push(...collectSourceFiles(path.join(dir, entry.name), rel)); | ||
| } else if (entry.isFile() && !isExcludedFromCopy(entry.name)) { |
There was a problem hiding this comment.
swizzle Markdown still copies plugins/headingLinks.a11y.chromium.spec.ts. It is not under __tests__/ and does not match .test., and it imports @playwright/test and the unpublished @astryxdesign/a11y-spec/storybook, so consumers cannot resolve it. Please also skip code harness files such as *.spec.ts/*.spec.tsx in this walk (or in isExcludedFromCopy), and add Markdown to the test-only regression.
| if (stat.isSymbolicLink()) { | ||
| throw new AstryxError( | ||
| `Refusing to write through destination symlink "${rel}".`, | ||
| [], | ||
| ERROR_CODES.ERR_PATH_TRAVERSAL, | ||
| ); | ||
| } |
There was a problem hiding this comment.
This also refuses links that stay inside the project (for example components → src/components), which main copies through and its docs allow. Whether that narrowing is intended, and whether it can ship as a patch fix, is a maintainer decision; no change is needed here until that is settled.
|
gentle ping @josephfarina sorry. |
…e the package (#9190) ## Exact decision needed What `astryx swizzle` promises about the copy it writes. Today a product team that swizzles a component to own its source gets a copy that often does not build: the copy imports Core helpers Core does not export. No current record says the copy must build, keep theme targets, or behave like the package component. This PR adds `spec:AST-110` (Swizzle output) only. Core approved the record on 2026-10-31. It stays `draft` until its co-owner, the CLI owner, agrees. A draft does not govern, so the `spec:AST-080` FR5 and FR7 swizzle cases and the `architecture:cli-surface` pointer land in the same pull request that makes AST-110 current; the record's Known gaps say so. ## Existing authority searched - `architecture:cli-surface` INV28: what `swizzle --list` reports. Says nothing about the copy's contents. - `spec:AST-035` FR11–FR12: which component an unqualified or Core-scoped `swizzle <Name>` copies. - `spec:AST-081` FR3: swizzle refuses to run outside a project. - `spec:AST-080` FR7: product rules stay outside `astryx-base`, which puts a swizzled copy above the theme layer. Its swizzle exception lands when AST-110 becomes current. - `@astryxdesign/build`: it sorts modules into its library pass (`astryx-base`) or product pass by path (`node_modules/@astryxdesign/`), so a copy in the product tree lands in the product layer. - `spec:AST-017` FR21: modules without a public contract stay internal; `./internal/*` is limited to Core and Lab. - `architecture:public-component-api` INV12 (anything reachable is public) and INV23 (each private data attribute has one owner module). - `architecture:layer-runtime`: the layer stack, modal outlet, and layer contexts that FR3 keeps single. - `spec:AST-030` FR11 and FR14: one test lane per surface; allowlisted triggers. - Searched `docs/**` and the CLI's command docs for swizzle, eject, and copy. The command doc only says imports that escape the component folder are rewritten. - Overlapping open work: #5101 (copy nested component subfolders) implements part of FR2; #8626 (gh lookup) affects how fast the copy runs. Neither decides what the copy promises. ## Decision - **FR1, builds on its own:** with the same Core version and a StyleX compiler, the copy type-checks and bundles with no edits. It imports only paths its owner package exports, never `./internal/*`. Swizzle reports the owner package's npm dependencies the copy imports (with their declared ranges); the copy builds once the product installs them. - **FR2, helpers come with it:** non-public modules the component reaches are copied with it and imported by relative path. Nested folders come too. Tests, stories, specs and docs stay behind. If an earlier swizzle already wrote a helper, an identical file is reused. A different file is never overwritten (not even with `--overwrite`): the new one is written alongside under a version-suffixed name, and only the new copy's imports point at it. - **FR3, shared runtime state stays single:** coordinating state (layer stack, modal outlet, interaction modality, bottom-sheet stack, and the one announcement channel per document of `spec:AST-086` FR9) and the contexts that connect providers to consumers live under registered, versioned keys. A copy and the package on the same version share them, so stacking, Escape and focus return work as one, a copied `useToast` reaches the package's `LayerProvider`, and identity symbols (brands, context keys) agree between copy and package. It holds in both directions: package components inside a copied Dialog deliver announcements inside that modal (`spec:AST-086` FR14), and package group context stops at the copy's layer boundary (`spec:AST-038` FR7). A copy on another version keeps its own store and never reads a different shape. - **FR4:** each private data attribute's owner module (INV23) that the component imports is copied whole, so callers, the copy included, still never write the attribute by hand. - **FR5:** theme targets, documented classes, data attributes and custom properties are unchanged. Swizzle marks its output directory with an `astryx-swizzle.json` file (owner package and version). `@astryxdesign/build` compiles modules under a marked directory in its library pass into `astryx-base`, below `astryx-theme`, so a theme's component overrides still apply. This holds for products on `@astryxdesign/build`. The stock StyleX plugins have no library-pass setting, so on them a copy's rules land above `astryx-theme`; the record lists that as a known gap. - **FR6:** keyboard, focus, roles, names, states, announcements and events match the package until the product edits the copy. - **FR7:** before a change to component source or the swizzle copy merges, every component swizzle can copy (Core's `--list` per `spec:AST-035` FR12, plus each integration package's components through `--package`) is ejected, type-checked, bundled with StyleX, and server-rendered, and a failure blocks the merge. Release checks add a real-browser render. CI impact of FR7, shaped with the CI and release owners: one step in the existing required test job, selected by the shared change-scope classification, with results in the single PR report. It uses standard runners and adds about +3 job-minutes on pull requests that change component source or swizzle code (≈ +2–3% of pull-request runner time). It adds no wall-clock time to green and no new runs or checks. These numbers are estimates until the first real run measures them. ## Rejected alternatives - Export the helpers copies need: anything reachable from a package path becomes public API (INV12), so internals would turn into permanent API to make a copy build. - Never copy stateful modules; import a contained package instance instead. That needs a public runtime entry with a compatibility promise only copies need, and it leaves a copy on another version without the state it needs. Core already keeps modality and the bottom-sheet stack in versioned per-document stores so duplicate bundles share state; FR3 makes that the rule. - Run the proof in the CLI smoke workflow: that workflow is not a required check, so a failure could not block, and it is already close to its time budget. ## Claim scope and non-goals The record governs only what a swizzled copy contains and promises, and the proof that keeps it true. It leaves out: - which component a name copies; - where the command runs; - how a product compiles StyleX; - keeping an edited copy in step with later Core releases; - making internal helpers public. ## Evidence and implementation relationship - Published 0.7.5 was built for real, covering all 112 names `swizzle --list` offers: 12 build and render, 89 fail to build, 9 build but render wrong, and 2 build with nothing to render. - Causes: - The import rewrite collapses `../X/file` to the public `@astryxdesign/core/X` entry, which lacks internal helpers (87 components). - Deep StyleX modules are missing from the exports map (12). - Copied styles land in the app's cascade layer above the theme's, so theme component overrides stop applying (9 today, 38 once imports resolve). FR5 now states the cascade rule. - Spec records and tests get copied (104), and nested folders are left out. - `--list` offers 6 folders that are not components. - On `main`, a full ledger of 154 components (Core, Lab, Charts, RichText, Vega) finds: - 32 pass every check, 96 don't bundle, 17 lose theme component overrides, and 1 behaves differently (Escape doesn't close a copied Lab MobilePowerSearch). - Copying every helper Core doesn't export raises passes to 48. What remains: - copied shared-state modules (a second live region; focus misses the combobox in a copied CommandPalette); - the cascade layer; - Core's private type additions and a unique-symbol identity split; - 16 copies that need the owner package's npm dependencies (d3, vega-util). - FR1, FR3 and FR5 cover each of these. - Running 112 separate CLI processes took 654 s locally, almost all of it start-up, so the proof copies in-process. - Response and file changes: - `swizzle.copy` lists each helper as written, reused or versioned, and each npm dependency with its range. - An existing component file still fails with `ERR_FILE_EXISTS` unless `--overwrite` is passed. - An existing helper never fails the command and is never replaced. - No implementation is in this PR. The CLI owner implements the copy changes (FR1, FR2, FR4, FR7). Core implements FR3's stores and contexts. The build package reads the FR5 marker, and the styling overview documents where a copy's rules land with and without it. ## Writing rubric results - R1 narration: none found. Intent, requirements, current-state impact and known gaps are in the present tense. - R2 research in the record: one finding, fixed. Ledger counts and CI estimates moved out of the record into this description; Known gaps keeps the causes only. - R3 evidence naming a change: none. Verification cells name checks and states. - R4 rejected alternatives over one line or outside a decision: two, in DEC-1 and DEC-2, one line each. - R5 pull request or issue references remaining: none in the record. - R6 ruled open questions still listing options: none. The record has no open questions; DEC-1 and DEC-2 carry Core's approval. ## Scope - [x] This PR contains specification records only. - [x] It records observable behavior and preserves equivalent internal implementations. - [x] Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract. - [x] Verification states the evidence layer and failure signal without prescribing CI job/workflow topology. - [x] It records one intentional durable decision, not a rescue for a separable tagalong. - [x] The canonical knowledge owner, affected current claims, and overlapping open work are named; any ownership collision is resolved or called out for human decision. - [x] Adjacent API, visual, accessibility, composition, and implementation facts remain outside scope unless this exact decision depends on them. - [x] Public text and artifacts contain no internal Meta context. ## Validation - `pnpm check:knowledge`: Knowledge templates and records are aligned. - Prettier: AST-110 clean. - `git diff --check`: clean.
Rebuilds the recursive copy on main's swizzle, which since meta#10085 also carries the private attribute owner modules a component imports. - A Core component's nested folders are copied (Table's plugins/), and an integration's folder stays flat. One sorted file list drives the pre-flight, the copy and the receipt; the owner-module walk reads each nested file from its own folder. - Imports that stay inside the component (../types from plugins/) stay relative; imports that leave it are rewritten to the owner package. - __tests__ and __snapshots__ folders and *.spec.ts(x) browser harnesses are left out at every depth (Markdown's headingLinks chromium spec). - Destination symlinks follow spec:AST-017 FR1/FR5: a folder linked elsewhere inside the project is written through, as released; a link out of the project is still refused by the existing confinement check. The blanket refusal of every destination symlink is dropped. - A destination held by the wrong kind of entry is refused before any write, even with --overwrite; a failed copy removes the folders it made. - The rewriteImports depth parameter is not carried: main's keep predicate covers it, and the copy tests check the depth behaviour end to end.
There was a problem hiding this comment.
One fix is needed before approval. Everything else checks out: Core components with nested folders now eject whole, imports inside the component stay relative, test-only files stay out, and folders linked inside the project keep working as before.
- Newly live check:
checkDestinationKindsbuilds its ownrefuseerror (packages/cli/api/swizzle/copy/copy.mjs:412-417) instead of callingwriteFailedfrompackages/cli/api/error.mjs, and the two have already drifted (the pre-flight'sEACCESmessage drops "(no permission)"), so please throwwriteFailed(segment, root, err)in thestatSynccatch, passEISDIR/ENOTDIRor an optional reason for the two wrong-kind refusals, and deleterefuse.
Two optional comment trims are noted inline. CI has not run on this head yet: a maintainer needs to add the ci:run label, and the earlier engineering-owner change request clears when that owner re-reviews.
[Automated review]
| const refuse = message => | ||
| new AstryxError( | ||
| `${message} Nothing was written.`, | ||
| [], | ||
| ERROR_CODES.ERR_WRITE_FAILED, | ||
| ); |
There was a problem hiding this comment.
This rebuilds writeFailed from api/error.mjs, which this file already imports: the same ERR_WRITE_FAILED code, project-relative path, errno and "Nothing was written." The two have already drifted: a pre-flight EACCES reads Could not write out/Table/Table.tsx: EACCES. Nothing was written., while the same failure during the write adds (no permission). Please throw writeFailed(segment, root, err) in the statSync catch, pass EISDIR/ENOTDIR (or an optional reason added to writeFailed) for the two wrong-kind refusals, and delete refuse.
| * A Core component is copied with its nested folders (Table's `plugins/`), | ||
| * test-only folders and harness files left out; an integration component's | ||
| * folder is copied flat. Every destination is checked before anything is | ||
| * written: it stays inside the project, through any symlink, and nothing of | ||
| * the wrong kind is in its place. |
There was a problem hiding this comment.
Optional: this paragraph takes the file header from 12 to 18 lines, and its facts already sit in the componentFilesOf and checkDestinationKinds JSDoc and the call-site comment. Consider dropping it.
| * Refuse, before anything is written and whatever `overwrite` says, a | ||
| * destination that something of the wrong kind already holds: a file where a | ||
| * folder must go, or a folder where a file must go. Symlinks are followed; |
There was a problem hiding this comment.
Optional: this first sentence runs 34 words. Suggested: "Refuse a destination that holds the wrong kind of entry: a file where a folder goes, or a folder where a file goes. The check runs before any write, even with overwrite."
* test(swizzle): cover destination symlinks Carries the destination-symlink tests from #5101 over to the merged swizzle code: an output folder, component folder, nested folder or file linked outside the project is refused before anything is written, with or without --overwrite, and a folder linked elsewhere inside the project is written through, nested folders included. The fixtures import the nested file, since the copy follows imports. Refs #5101 Co-authored-by: jiunshinn <[email protected]> * test(swizzle): keep the file's existing formatting Only the destination-symlink block is added; the rest of the file is as on main.
|
(Posted by Cindy's agent.) Thank you, @jiunshinn! This landed through #10197 (swizzle copies the whole module graph a component reaches, including nested subdirectories) and #10484 (your symlink tests, with you credited as co-author), so I'm closing this as superseded. |
Closes #3506
Clean-room provenance: implemented from the issue description and source only; no code from the prior closed PRs (#3507, #4347, #4445) was opened, read, or consulted.
astryx swizzle Tablepreviously copied only 17 top-level files while its barrel still referenced missingplugins/*modules. It now copies all 47 source files with their directory structure intact. A single file set drives copying, overwrite checks, and the receipt. Import rewriting accounts for each file's depth, preserving intra-component relative imports while rewriting escaping imports to the owner package.Before creating directories or writing files, swizzle checks every destination path segment below the project root and rejects symlinks, including dangling file links.
--overwritedoes not bypass this check. Regression tests cover output-root, component-root, nested-directory, existing-file, dangling-file, and in-project symlinks, and verify that rejection leaves no partial output.Recursive traversal is limited to core component directories. Integration discovery identifies a same-stem entry file, not an exclusively owned directory tree, so integrations retain their previous flat copy behavior. A shared-directory regression confirms that swizzling Alpha does not newly copy unrelated nested files or overwrite consumer edits there. The pre-existing copying of top-level sibling integration files remains unchanged; this PR does not define a new integration ownership policy.
Validation:
pnpm lint:strict, including repository checks: passed.pnpm build: passed.pnpm test: 10,379 passed, 2 failed. Both failures involve case-sensitive component/hook filename expectations on this local filesystem. Their failing behaviors also reproduce on untouched headfd227184: lowercasebuttonresolves instead of throwing, andmediaqueryresolves withuseMediaquery.doc.mjscasing.Maintainer rebuild on main (merge commit on top; jiunshinn's commits unchanged)
Main's swizzle changed under this branch: since #10085 it also carries the private attribute owner modules a component imports. The recursive copy is rebuilt on that code, following the maintainers' ruling under spec:AST-017 FR1/FR5.
plugins/), and an integration's folder stays flat. One sorted file list drives the pre-flight, the copy and the receipt. The owner-module walk reads each nested file from its own folder.../typesfromplugins/) stays relative; one that leaves it is rewritten to the owner package.__tests__and__snapshots__folders and*.spec.ts/*.spec.tsxbrowser harnesses are left out at every depth. A Markdown regression checksplugins/headingLinks.a11y.chromium.spec.ts.components→src/components) is written through, as in released versions. A link out of the project, dangling or not, is still refused by the existing confinement check before anything is written. The earlier blanket refusal of every destination symlink is dropped, and a test covers the in-project case.--overwrite. A copy that fails part-way removes the folders it created.rewriteImports' depth parameter. Main's keep predicate covers it, and the copy tests check depth end to end.Verification: the swizzle copy, routing and path-safety suites and
write-failure.test.mjspass (78). One path-safety manifest test timed out once under M5 load and passes alone. CLI type check, strict lint and check:changesets pass.