Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for this — the trade you're naming is real and importUserModule is the right place for the switch.
It isn't holding yet. astryx doctor re-imports the config directly at doctor.mjs:328, so under the gate it prints "ignoring …; running on built-in data only" and then executes that same file. astryx component <Name> runs a doc module from the checkout through loadDocs at component-loader.mjs:141 — its neighbour loadComponentDoc goes through the gate, loadDocs doesn't. About nine bare await import()s of checkout paths remain.
ASTRYX_NO_PROJECT_CODE=1 astryx doctor # config runs anywayIdeally I'd like those loaders routed through importUserModule too, so the README sentence is true when it ships. Also CI is red on a missing @param for noteConfigSkipped (project.mjs:43).
Is routing them all through the one loader workable, or is something in loadDocs making that hard?
If you'd rather talk it through with someone, we're in Discord.
[Reviewed by Robohands]
|
|
||
| /** Say once per process why a present config is being ignored. */ | ||
| let configSkipNoted = false; | ||
| function noteConfigSkipped(configPath) { |
There was a problem hiding this comment.
Needs a @param {string} configPath.
There was a problem hiding this comment.
Added, and the helper typechecks now.
There was a problem hiding this comment.
Still in place on the rebased head: noteConfigSkipped carries @param {string} configPath and typecheck:strict passes.
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for adding this safety switch. We previously asked for every checkout-backed loader to honor it and for the new helper to typecheck; this exact head has not changed, so both are still open.
With ASTRYX_NO_PROJECT_CODE=1, astryx doctor still executes a fixture config after saying it was ignored, and astryx component still executes a fixture doc module. An agent can therefore opt out and still run checkout code. CI also still fails because noteConfigSkipped(configPath) has an implicit any.
Could you cover every project-code import path, add end-to-end probes for these two commands, and add the missing @param?
If you'd rather talk it through with someone, we're in Discord.
[Reviewed by Robohands]
|
Thanks for running it — you were right, the switch wasn't connected to most of the loaders. Reworked so the README sentence is true:
Full CLI suite is green locally except |
74b441a to
ae4d15f
Compare
cixzhang
left a comment
There was a problem hiding this comment.
Thanks for routing doctor and component docs through the gate — both new probes pass, and the missing JSDoc is fixed. We previously asked for every checkout-backed loader; that part is still incomplete.
ASTRYX_NO_PROJECT_CODE=1 astryx theme build hostile-theme.mjs still executes the file and emits output because importThemeModule calls jiti directly. The rewrite also leaves exact-head CI red: API type generation reports 24 errors and strict lint reports two unused imports.
Could you gate the theme source before either loader runs and get CI green? If you'd rather talk it through with someone, we're in Discord.
[Reviewed by Robohands]
ae4d15f to
5dd9e88
Compare
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Discovery-backed commands load the checkout's astryx.config.*, the integration manifests it names (and the installed ones autolink finds), doc modules, template specs, codemods, and theme sources. All of those execute on import, which is the right trade in a workspace the operator trusts and the wrong one in CI, triage, and agent runs over arbitrary checkouts. ASTRYX_NO_PROJECT_CODE=1 opts out. The gate lives in importUserModule, the chokepoint every user-authored module flows through, and carves out the CLI's own package root so shipped topics, templates, and command modules keep loading. Every loader that did not go through it now does (component-loader's loadDocs, the docs catalog detail/list loaders, search, string-utils' keyword scan, doctor's config re-import), or asks the gate itself where a different jiti is needed (template-adapter's JSX jiti, external blocks). Project.load skips a present config with a single stderr notice and loads no manifest: configured, autolinked, or the package being authored. `theme build` refuses a theme source outside the CLI before jiti, the family preloader, or the eval fallback runs, exiting 1 with ERR_THEME_LOAD and writing nothing. Default behavior with the variable unset is unchanged.
5dd9e88 to
a0348cf
Compare
|
Thanks for the precise repro. Rebased onto current main and closed the remaining gaps:
|
There was a problem hiding this comment.
Thanks for hardening the CLI against executing code from untrusted checkouts. Approval is waiting for a maintainer to provide or identify the current spec governing the new ASTRYX_NO_PROJECT_CODE=1 contract. Three implementation gaps also remain:
- Text
astryx componentstill loads a theme selected by the checkout'spackage.jsonthrough an ungatedrequire(); please gate it here or make the separate fix a required prerequisite and cover the command path. - Core component docs resolve outside the CLI package root and are refused, so the documented
astryx component Buttonbuilt-in example does not work under the gate. - Multiple
astryx.config.*files throw before safe mode reaches its skip path.
Please preserve trusted Core docs as built-in data and handle multiple config names without executing them, with focused side-effect and success probes.
[Automated review]
cixzhang
left a comment
There was a problem hiding this comment.
The trust-boundary goal is right, but the current implementation is not safe or compatible enough to land at exact head a0348cf9cc621bf3e027517ef94f246f0cccac24. The opt-in environment switch still allows theme execution on text component --list, refuses legitimate installed Core docs needed by ordinary inspection, and lets duplicate config files fail before the safe-mode decision. Please wait for PR 6491 to settle discoverability/environment-control policy, then rework the boundary so supported safe inspection is discoverable, trusted installed/version-matched Astryx data is distinguished from checkout code, project code is not executed on the safe path, and duplicate project config is ignored rather than parsed there. The static theme-metadata direction from PR 5525 should remove the theme execution path rather than add another gate.
There was a problem hiding this comment.
Thanks for hardening the CLI against executing code from untrusted checkouts — that trust-boundary goal is worth keeping. It cannot land in this shape, because the governing spec has now landed on main in #6491 and differs from this implementation in a large way.
AST-017 FR14 states: "The CLI MUST NOT define or read an Astryx-owned environment variable for any purpose." The new claims also require supported behaviour to be discoverable in generated help and the machine-readable manifest, any global scope to be proven with a manifest-derived command matrix (FR15), a cross-cutting guarantee to fail closed for new extension points rather than cover only audited loaders (FR16), suppressed work to be identified in every successful machine-readable result (FR17), and programmatic control to be an explicit per-call input rather than ambient process state (FR18).
Please rework safe inspection onto a documented, scoped, per-call surface with observable reduced-capability results. In the same rework, and coordinated with #5525 for theme loading:
- Text
componentoutput still loads a checkout-selected theme through an ungatedrequire(); remove theme execution from the safe path (static metadata direction) and add a command-level side-effect probe. - Core component docs resolve outside the CLI package root and are refused, so the documented
astryx component Buttonbuilt-in example does not work; preserve trusted installed, version-matched Core docs as built-in data. - Multiple
astryx.config.*files throw before the safe path can skip them; ignore duplicate project config on that path rather than throwing or parsing it.
[Automated review]
Summary
Discovery-backed commands (
component,search,docs,discover,template,doctor,layout, ...) load the checkout'sastryx.config.*, the integration manifests it names (and the installed ones autolink finds), doc modules, template specs, codemods, and theme sources. All of those execute on import. That is the right trade in a workspace the operator trusts and the wrong one in CI, triage, and agent runs over arbitrary checkouts. This adds the opt-out:ASTRYX_NO_PROJECT_CODE=1keeps the whole CLI on built-in data.Changes
importUserModule(the chokepoint every user-authored module flows through) refuses under the gate before any of its loaders (jiti, fresh jiti, CommonJSrequire, native import) runs, with an error naming the variable. It carves out the CLI's own package root (isCliShippedPath) so built-in topics, templates, and command modules keep loading.isProjectCodeGatedandprojectCodeGateMessageare exported for the two loaders that need a different jiti.Project.loadchecks the gate before touching a config: a presentastryx.config.*is acknowledged once on stderr and skipped, and no integration manifest is loaded (configured, autolinked, or the package being authored), so read commands degrade to built-ins instead of erroring.loadDocs(component-loader), the docs catalog detail and list loaders,search's doc loader, string-utils' keyword scan, anddoctor's config re-import (which now reports "config present but not loaded" instead of executing the file it just said it ignored).template-adapterkeeps its JSX-capable jiti but asks the gate itself and skips external blocks entirely.astryx theme buildrefuses a theme source outside the CLI before any loader runs (jiti sync and async paths, the family preloader, the legacy eval fallback): exit 1,ERR_THEME_LOAD, one-line message, nothing written. Covers--check,--family, and--watch.@astryxdesign/core,jscodeshift) are not in scope.Audit of checkout-backed import sites in
packages/cliNon-test, non-dist code. "Gated" means the site cannot execute a checkout module under
ASTRYX_NO_PROJECT_CODE=1.foundation/fs/module-loader.mjsimportUserModule(jiti, fresh jiti, CommonJSrequire, native import)foundation/fs/module-loader.mjsloadModuleWithParserimportUserModulefoundation/config/project.mjsconfig load,autolinkIntegrations,loadLocalIntegrationfoundation/integrations/integrations.mjsmanifest importimportUserModule; never reached under the gatefoundation/integrations/autolink.mjsloadIntegrations; skipped byProject.loadunder the gatefoundation/discovery/component-loader.mjsloadComponentDocimportUserModule(already so on main)foundation/discovery/component-loader.mjsloadDocsimport())foundation/discovery/docs-discovery.mjstopic importimportUserModule; only reached for integrations, which never load under the gatefoundation/discovery/template-adapter.mjsloadIntegrationDocloadModuleWithParserfoundation/discovery/template-adapter.mjsloadDocModule(JSX jiti andimport())foundation/discovery/template-adapter.mjsdiscoverExternalBlocks[]under the gatefoundation/text/string-utils.mjskeyword scanapi/docs/_adapter.mjstopic and translation importimportUserModuleapi/docs/list/list.mjsdescription importapi/search/search.mjsloadModuleDocapi/doctor/doctor.mjsconfig re-importimportUserModuleapi/doctor/doctor.mjs_require.resolvepeer-dep checksapi/theme/build/build.mjsjiti theme import,evalModule,evalfallback, family registryimport(),preloadFamilySource;core-interception.mjscreateRequire(fromFile)(specifier)refuseGatedThemeSourcebefore any loader is createdapi/theme/build/build.mjscreateJiti(...).resolvecallsapi/theme/build/build.mjsimport('@astryxdesign/core/theme');import('jscodeshift')in codemods, upgrade, theme-discovery; babel plugin require inauthoring/shadcnassets/codemods/integration-discovery.mjscodemod loadloadModuleWithParser; integrations never load under the gateapi/upgrade/_adapter.mjspost-codemod hookexecFileapi/gap-report/gap-report-worker.mjshandler importimportUserModule; the worker sharesprocess.env, and handler entries derive from the config and loaded integrations, both empty under the gateapi/gap-report/gap-report.mjsexecFile('gh', ...),api/swizzle/_github.mjsclients/cli/index.mjscommand module imports,commands/template.mjslazy imports,foundation/fs/paths.mjspnpapiscripts/*.mjs,test/drift/docs-drift.mjsclients/cli/lib/resolve-theme.mjsrequireofpackage.jsonastryx.theme/ASTRYX_THEMEisProjectCodeGatedfrommodule-loader.mjsso the carve-out and message stay sharedTest plan
packages/cli/clients/cli/commands/no-project-code.test.mjs(12 end-to-end probes): every fixture module sets a global when it executes; the real CLI runs in-process against it and the global must stay unset, so a loader that slips past the gate fails the suite. Coversdoctor(text and--json),component <Name>from a repo-layout checkout, the fuzzy-match path (component Buton),search(with and without--type),componentandcomponent --listwith a hostile integration that is both configured and declared as a dependency (so autolink is exercised),docslist plus a built-in detail,template --listwith a hostile external block,theme build(text,--jsoncode,--familywith a preloaded intermediary), plus a control proving the same theme fixture executes and builds with the variable unset.module-loader.test.mjs(refusal for.mjs,.js, and.tsincludingfresh, shipped-path carve-out, exact-value check),project.test.mjs(config skip with stderr notice, no autolink, no local integration; spies prove the loaders are not even called),integrationDocs.test.mjs(loadReferenceDocsrefuses a project topic and still loads a built-in with--lang dense).importUserModulegate fails 6, the config skip 1, the autolink guard 1, the local-integration guard 1, the doctor early return 2 (also with the old raw import restored), theloadDocs, search, string-utils, and docs-adapter rewrites 1 each, the external-blocks guard 1, the theme member gate 2, both theme gates 3. The family-level loop inthemeBuildFamilyis redundant with the member-level refusal (the plan always orders a selected member first) and is kept as belt-and-braces.pnpm -F @astryxdesign/cli typecheck:strict,typecheck:template-docs,node .github/scripts/cli-api-types-verify.mjs(regenerates the api types),ASTRYX_STRICT_LINT=1 eslintand plaineslinton every changed file,pnpm check:cli-structure,pnpm check:changesets,readme:check, the copyright check, andpnpm vitest run --project node packages/cli(4031 passed, 6 skipped; the only failures were environment-specificpnpm exec tscinvocations and load timeouts that pass on rerun).Notes
node_modulesthat the CLI itself depends on (for example@astryxdesign/core) is out of scope, since refusing it would break every command; the README says so.ERR_UNKNOWNin the JSON envelope). A dedicated error code is a small follow-up if wanted;theme builduses the existingERR_THEME_LOAD.@astryxdesign/clipatch).