@@ -4,6 +4,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs'
import { occurrences , readSource } from './helpers.ts'
import { adminPages } from '../src/router/routes.ts'
import { COMPANY_SCOPED_PAGES , SUPER_ADMIN_ONLY_MENU_KEYS } from '../src/config/company-scope.ts'
import { companyTabAppliesTo } from '../src/layout/company-tab-model.ts'
const read = ( p : string ) = > {
assert . ok ( existsSync ( p ) , ` 护栏读不到 ${ p } :api 文件改名了,清单必须同步(别把用例改成"不存在就跳过") ` )
@@ -69,9 +70,12 @@ function escapeRegExp(text: string): string {
}
/**
* 全部 22 个字面发送口:批次 1 的任务看板 5 处 + 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页)12 处
* 全部 21 个字面发送口:批次 1 的任务看板 5 处 + 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页)7 处
* + 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」那两页)4 处
* + 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」里的用户管理)1 处。
* + 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」里的用户管理)1 处
* + 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)1 处
* + 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」)3 处:菜单目录 / 新建菜单 / 用户管理里的授权树。
* 批次 2 原 12 处里的品牌库 1 处 + 商品类目 4 处,随 2026-10-06「这两页退回全平台共享」一并摘掉。
*
* <p>`window` 的取法:本轮实扫的 own(到自己那行的距离)+ ≥150 余量,且当同文件还有下一个同名发送口时必须
* `window < next`。own/next 不写死在这里——下面「窗口与真文件对平」那条用例逐处从真文件重算,
@@ -94,15 +98,10 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
{ menuKey : 'admin_dedupe_total_data' , file : 'src/pages/asin/dedupe-total-api.ts' , fn : 'fetchDedupeTotalList' , line : 'if (params.companyId != null) query.company_id = params.companyId' , window : 400 , title : 'GET /dedupe-total-data 列表' } ,
{ menuKey : 'admin_dedupe_total_data' , file : 'src/pages/asin/dedupe-total-api.ts' , fn : 'fetchDedupeTotalGroups' , line : 'http.get<unknown>(DEDUPE_GROUPS_ENDPOINT, { params: companyId != null ? { company_id: companyId } : {} })' , window : 400 , title : 'GET /shop-manages/groups 分组候选(与店铺管理同源,两页口径要对得上)' } ,
{ menuKey : 'admin_dedupe_total_data' , file : 'src/pages/asin/dedupe-total-export.ts' , fn : 'buildDedupeExportParams' , line : 'if (companyId != null) params.company_id = String(companyId)' , window : 800 , title : 'GET /dedupe-total-data/export 导出' } ,
{ menuKey : 'admin_invalid_asin_data' , file : 'src/pages/invalidasin/invalid-asin-api.ts' , fn : 'fetchInvalidAsinPage' , line : 'if (query.companyId != null) params.company_id = query.companyId' , window : 400 , title : 'GET /invalid-asin-data 列表(品牌数据库)' } ,
{ menuKey : 'admin_query_asin' , file : 'src/pages/asin/query-asin-api.ts' , fn : 'fetchQueryAsinList' , line : 'if (params.companyId != null) query.company_id = params.companyId' , window : 400 , title : 'GET /query-asins 列表' } ,
{ menuKey : 'admin_query_asin' , file : 'src/pages/asin/query-asin-export.ts' , fn : 'buildQueryAsinExportParams' , line : 'if (companyId != null) params.company_id = String(companyId)' , window : 700 , title : 'GET /query-asins/export 导出' } ,
{ menuKey : 'admin_skip_price_asin' , file : 'src/pages/asin/skip-price-api.ts' , fn : 'fetchSkipPriceList' , line : 'if (params.companyId != null) query.company_id = params.companyId' , window : 400 , title : 'GET /skip-price-asins 列表(最低价 ASIN) ' } ,
{ menuKey : 'admin_skip_price_asin' , file : 'src/pages/asin/skip-price-export.ts' , fn : 'buildSkipPriceExportParams' , line : 'if (companyId != null) params.company_id = String(companyId)' , window : 1000 , title : 'GET /skip-price-asins/export 导出(本批新建:原先 href 不带任何参数=恒导全平台)' } ,
{ menuKey : 'admin_product_categories' , file : 'src/pages/asin/product-category-api.ts' , fn : 'fetchProductCategoryTree' , line : 'if (companyId != null) params.company_id = companyId' , window : 450 , title : 'GET /product-categories 类目树' } ,
{ menuKey : 'admin_product_categories' , file : 'src/pages/asin/product-category-api.ts' , fn : 'searchProductCategories' , line : 'if (companyId != null) params.company_id = companyId' , window : 450 , title : 'GET /product-categories/search 搜索' } ,
{ menuKey : 'admin_product_categories' , file : 'src/pages/asin/product-category-api.ts' , fn : 'fetchProductCategoryChildren' , line : 'if (companyId != null) params.company_id = companyId' , window : 450 , title : 'GET /product-categories/children 懒加载子级' } ,
{ menuKey : 'admin_product_categories' , file : 'src/pages/asin/product-category-export.ts' , fn : 'buildProductCategoryExportUrl' , line : 'if (companyId != null) params.push(`company_id=${companyId}`)' , window : 400 , title : 'GET /product-categories/export 导出(字符串拼接而非对象,锚整条 push)' } ,
// ↓ 批次 3 的两页(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。
// 撞款三处各锚一个左值名(query/params/itemsQuery),店铺数据记录一处。
{ menuKey : 'admin_shop_data_duplicate_check' , file : 'src/pages/tasks/duplicate-console-api.ts' , fn : 'fetchDuplicateConsole' , line : 'if (companyId != null) query.company_id = companyId' , window : 400 , title : 'GET /duplicate-check-console 指标/店铺/撞款全集/分组统计' } ,
@@ -111,6 +110,16 @@ const SEND_POINTS: ReadonlyArray<SendPoint> = [
{ menuKey : 'admin_shop_data_crawl_tasks' , file : 'src/pages/tasks/shop-data-api.ts' , fn : 'fetchShopDataTaskList' , line : 'if (companyId != null) query.company_id = companyId' , window : 400 , title : 'GET /shop-data-crawl-tasks 店铺数据记录列表' } ,
// ↓ 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
{ menuKey : 'admin_users' , file : 'src/api/users.ts' , fn : 'fetchUserList' , line : 'if (params.companyId != null) query.company_id = params.companyId' , window : 400 , title : 'GET /users 用户列表(后端早就认这个参数,断的是前端没发)' } ,
// ↓ 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。
{ menuKey : 'admin_shop_keys' , file : 'src/pages/shop/shop-key-api.ts' , fn : 'fetchShopKeyList' , line : 'if (params.companyId != null) query.company_id = params.companyId' , window : 400 , title : 'GET /shop-keys 紫鸟令牌列表(不带 company_id 时非超管仍由后端会话裁剪,超管点了 tab 才会变)' } ,
// ↓ 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分,现在的默认归到 admin 下」,定案「每家公司一套树」)。
// 三处都锚同一串 TASK_CENTER_SEND_LINE,但分属两个文件 ⇒ (文件, 整行) 分组各成一组,钉数与条数仍逐处对平。
// 窗口取 300:两处 menu-manage 的 own 是 110/130,而 fetchMenuManageNodes 到 createMenu 那行的 next 是 611
// ⇒ 300 够得着自己、够不到隔壁(这三个数由下面「窗口与真文件对平」那条用例逐处从真文件重测,注释过期即红)。
// user-menu-auth-api 那处一条发送口喂两个 GET(admin/app 两类各一支,共用同一个 query 展开)⇒ 一函数一钉。
{ menuKey : 'admin_columns' , file : 'src/pages/account/menu-manage-api.ts' , fn : 'fetchMenuManageNodes' , line : TASK_CENTER_SEND_LINE , window : 300 , title : 'GET /permission-menus 目录(超管不带就把两家的同名行混成一排下发)' } ,
{ menuKey : 'admin_columns' , file : 'src/pages/account/menu-manage-api.ts' , fn : 'createMenu' , line : TASK_CENTER_SEND_LINE , window : 300 , title : 'POST /permission-menus 新建:归属由端点参数决定,前端不从树里猜' } ,
{ menuKey : 'admin_users' , file : 'src/pages/account/user-menu-auth-api.ts' , fn : 'fetchGrantableMenus' , line : TASK_CENTER_SEND_LINE , window : 300 , title : 'GET /permission-menus?grantableOnly 授权树:一家一套树后取错公司=已授权勾不上、提交必判无效' } ,
]
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径)。 */
@@ -206,17 +215,24 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
note : '列表窄了而下拉不窄 = 两页口径对不上,且下拉能选到别家的组' ,
} ,
] ,
// 批次 2 的五 页:取值口钉全部由 SEND_POINTS 现算(一页几处发送口就几条钉),
// 批次 2 剩下的三 页:取值口钉全部由 SEND_POINTS 现算(一页几处发送口就几条钉),
// 手写一份就会和表漂开——那正是复评 I-1 拆条要避免的形状。
// admin_invalid_asin_data / admin_product_categories 两页 2026-10-06 退回全平台共享,
// 已不在注册表里 ⇒ 这里的条目一并摘掉(留着是死表项,"不得回流"由文件末尾那条反向钉看守)。
admin_dedupe_total_data : pinsFor ( 'admin_dedupe_total_data' ) ,
admin_invalid_asin_data : pinsFor ( 'admin_invalid_asin_data' ) ,
admin_query_asin : pinsFor ( 'admin_query_asin' ) ,
admin_skip_price_asin : pinsFor ( 'admin_skip_price_asin' ) ,
admin_product_categories : pinsFor ( 'admin_product_categories' ) ,
// 批次 3 的两页同样由 SEND_POINTS 现算(撞款控制台三处发送口 = 三条钉)。
admin_shop_data_duplicate_check : pinsFor ( 'admin_shop_data_duplicate_check' ) ,
admin_shop_data_crawl_tasks : pinsFor ( 'admin_shop_data_crawl_tasks' ) ,
admin_users : pinsFor ( 'admin_users' ) ,
// 批次 5(店铺密钥)同样由 SEND_POINTS 现算:这一页只有一个发送口(列表),
// 新增/编辑/删除/白名单检测四支都不带公司参数——归属由后端从操作者会话推导(writeCompanyId 闸门)。
admin_shop_keys : pinsFor ( 'admin_shop_keys' ) ,
// 批次 6(菜单权限):菜单目录 + 新建两处,都由 SEND_POINTS 现算。
// 编辑/删除/重排三支**故意不带**参数——归属由那一行的 id 与操作者公司共同判定,跨公司写后端 403
// (见 docs/ops/menu-company-tree-design-2026-10-06.md §5),给它们发 company_id 反而是第三处口径。
admin_columns : pinsFor ( 'admin_columns' ) ,
}
/** 严格判据的分母由本轮实扫得出(修完不许恒绿也不许恒红):求值了几条 shape、其中几条通过。 */
@@ -303,11 +319,13 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
// 不许让另一支用例替我证明"这串本来就会被匹配到")。
// ⚠ 身份要说清:下面这几条是对**字面量字符串**求值的探针,只证明判据形状没写坏
// (正样本匹配得出 ⇒ 不恒红;窗口外的负样本不匹配 ⇒ 窗口真有界,删一处不会靠隔壁过关),
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那 17 条 shape 对真实文件的求值 + 变异 自证。
// ⚠ 分母是本轮实扫的表条数(批次 1 的 5 + 批次 2 的 12 + 批次 3 的 4 + 批次 4 的 1)。这条只防"整表被摘空/被改窄",
// 逐处脱管由下面两条(对平闸门 + 窗口对平)负责。
assert . ok ( SEND_POINTS . length >= 22 ,
` 发送口表只剩 ${ SEND_POINTS . length } 条(批次 1+2+3+4 实扫 22 条)⇒ 有人把钉从表里摘了,取值口看守成空 ` )
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那批 shape(条数由 strictPinsEvaluated 当场 自证)
// 对真实文件的求值 + 变异自证。
// ⚠ 分母是本轮实扫的表条数(批次 1 的 5 + 批次 2 的 7 + 批次 3 的 4 + 批次 4 的 1 + 批次 5 的 1 + 批次 6 的 3;
// 批次 2 原 12 条里的品牌库 1 条 + 商品类目 4 条随 2026-10-06「这两页退回全平台共享」摘掉)。
// 这条只防"整表被摘空/被改窄",逐处脱管由下面两条(对平闸门 + 窗口对平)负责。
assert . ok ( SEND_POINTS . length >= 21 ,
` 发送口表只剩 ${ SEND_POINTS . length } 条(批次 1+2+3+4+5+6 实扫 21 条)⇒ 有人把钉从表里摘了,取值口看守成空 ` )
for ( const p of SEND_POINTS ) {
const shape = pointShape ( p )
const compliant = pointCompliant ( p )
@@ -330,7 +348,7 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
// 这一条杀的是「把 TASK_CENTER_SEND_POINTS 删剩 4 行」——少一条钉就等于少一处看守,而 5 条 shape 谁都不会红。
// 路线 ②(occurrences 计数)在这里只当"钉数与发送口条数对平"的闸门,不当"是哪一处"的判据:
// 计数回答不了"哪三处"(把一处重复写三遍、另一处删掉,计数照样对平),所以主判据仍是路线 ① 的函数名锚 + 有界窗口。
// 分母按 (文件, 整行) 而不是按文件:批次 2 的 product-category-api .ts 一个文件三处发送口、三处是逐字同一行,
// 分母按 (文件, 整行) 而不是按文件:任务看板的 task-center .ts 一个文件三处发送口、三处是逐字同一行,
// 按文件计只钉得出"3 条"这个数,按行计才和 occurrences 同一粒度;三个 *-export.ts 的行各只出现 1 次,同理。
const grouped = new Map < string , { readonly file : string ; readonly line : string ; pinned : number } > ( )
for ( const p of SEND_POINTS ) {
@@ -340,7 +358,7 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
else grouped . set ( key , { file : p.file , line : p.line , pinned : 1 } )
}
assert . equal ( grouped . size , 17 ,
` 发送口表按 (文件, 整行) 应聚成 17 组(22 处发送口),现在却有 ${ grouped . size } 组 —— 表被改形状了,对平判据失去分母 ` )
` 发送口表按 (文件, 整行) 应聚成 17 组(21 处发送口),现在却有 ${ grouped . size } 组 —— 表被改形状了,对平判据失去分母 ` )
for ( const g of grouped . values ( ) ) {
const actual = occurrences ( stripComments ( read ( g . file ) ) , g . line )
assert . equal ( g . pinned , actual ,
@@ -357,7 +375,8 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
// own = 从 `function <fn>(` 的括号后到自己那一行的距离 ⇒ 必须 < window(函数体写长 = 假红,fail-closed 可接受);
// next = 到同文件**下一条同名发送行**开头的距离 ⇒ 存在时必须 > window(否则删一处还有隔壁顶着,这条钉就是摆设)。
// 隔壁的"名字"用的是自己的整行,所以 next 只在同文件有逐字同行的另一处时才有意义:
// product-category-api.ts 三处同行( next 实测 705/929/无)是这一族唯一的真冲突面,其余 14 处 own 唯一。
// product-category-api.ts 那组( 三处同行) 2026-10-06 随「商品类目退回全平台共享」摘掉了;
// 这一族剩下的真冲突面只有任务看板:task-center.ts 三处逐字同行、task-center-model.ts 两处,其余各文件唯一。
for ( const p of SEND_POINTS ) {
const src = stripComments ( read ( p . file ) )
const anchor = 'function ' + p . fn + '('
@@ -477,6 +496,48 @@ test('发送口的第二实参:task-center 五处 http.get 必须把 query 交
}
} )
/**
* 1b ④ 的那一半缺口(批次 5 补,2026-10-06 变异自证 M9 实测存活):上面那支按**端点 URL 字面量**锚,
* 取样文件只有 `src/api/task-center.ts`。店铺密钥这一页的 GET 写的是 `http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: query })`
* ——端点是模块常量、调用还带泛型,那条正则两头都锚不到。把 `{ params: query }` 整段删掉后,
* `if (params.companyId != null) query.company_id = params.companyId` 那一行逐字还在 ⇒ 取值口五判据全绿、
* 编译器一声不响、URL 里没有 company_id:正是 1b ④ 当初要杀的那一形,只是换了一个文件。
*
* <p>判据换成「整行字面量 + 同文件 GET 总条数对平」:锚整行是因为常量名就是这一处的稳定身份,
* 对平是因为只钉一行的话,第二处新 GET 忘了带 params 也照样没人红(与上面「同一 URL 只许一处调用」同理)。</p>
*/
const CONSTANT_ENDPOINT_GET_PINS : ReadonlyArray < { readonly file : string ; readonly fn : string ; readonly call : string } > = [
{ file : 'src/pages/shop/shop-key-api.ts' , fn : 'fetchShopKeyList' , call : 'http.get<unknown>(SHOP_KEYS_ENDPOINT, { params: query })' } ,
]
test ( '非字面量端点的发送口:query 必须交给带 params 的第二实参,且同文件 GET 条数与登记表对平(1b ④ 的另一半)' , ( ) = > {
assert . ok ( CONSTANT_ENDPOINT_GET_PINS . length >= 1 , '常量端点登记表为空 ⇒ 这一族的第二实参没人看守' )
const byFile = new Map < string , number > ( )
for ( const p of CONSTANT_ENDPOINT_GET_PINS ) byFile . set ( p . file , ( byFile . get ( p . file ) ? ? 0 ) + 1 )
for ( const p of CONSTANT_ENDPOINT_GET_PINS ) {
const src = stripComments ( read ( p . file ) )
// ① 判据自证(正样本):登记的那一行本身必须含 params,否则下面的对平是在钉一个坏形状。
assert . ok ( p . call . includes ( ', { params' ) , ` 登记表里「 ${ p . call } 」不含 params 第二实参 ⇒ 这条判据恒红 ` )
// ② 判据自证(负样本):删掉第二实参后必须匹配不出自己,否则"带没带 params"都算过。
assert . equal ( p . call . replace ( ', { params: query }' , '' ) . includes ( p . call ) , false ,
` 删掉 { params: query } 之后「 ${ p . call } 」仍然自匹配 ⇒ 判据只看得到端点,杀不了这一记变异 ` )
// ③ 函数身份:这一处 GET 必须由它自己的函数发出。
assert . equal ( occurrences ( src , ` function ${ p . fn } ( ` ) , 1 ,
` ${ p . file } 里「function ${ p . fn } (」出现 ${ occurrences ( src , ` function ${ p . fn } ( ` ) } 次(要求 1):函数改名或被复制,这一行锚对不上是谁发的 ` )
// ④ 真文件求值:这一行必须逐字在场一次。
const hits = occurrences ( src , p . call )
assert . equal ( hits , 1 ,
` ${ p . file } 里带 params 实参的「 ${ p . call } 」匹配到 ${ hits } 处(要求 1): `
+ '0 处 = 发送口把 query 丢了(后端收不到 company_id、接口照旧 200、切 tab 一动不动),多于 1 处 = 有第二处同形调用没人钉' )
}
// ⑤ 同文件 GET 总条数对平:新增一处 http.get 而没登记 ⇒ 当场红,不留"新那处还没人管"的默认分支。
for ( const [ file , pinned ] of byFile ) {
const src = stripComments ( read ( file ) )
const actual = occurrences ( src , 'http.get' )
assert . equal ( actual , pinned ,
` ${ file } 实扫到 ${ actual } 处 http.get,登记表只有 ${ pinned } 条 —— 有一处 GET 的第二实参没人看守 ` )
}
} )
test ( '反向:把 company_id 当查询参数用的取数模块必须被清单认领(防止"筛了但没人知道这页参与") ' , ( ) = > {
const claimed = new Set ( COMPANY_SCOPED_PAGES . flatMap ( ( p ) = > p . apiFiles ) )
const scanned = requestModules ( )
@@ -506,7 +567,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
* 症状回到裁决 1 想避免的那一型。</p>
*
* <p>判据形状:从 `watch(() => companyTab.activeId, …)` 那**一条语句**取文本(正则在第一个
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;表里这九 页今天都没有那种写法,由下面的取样自检兜着)。
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;表里这十 页今天都没有那种写法,由下面的取样自检兜着)。
* 反向钉与正样本同支(全局约束 15,三条前提不成立就是探针失效、当场红,不许静默空跑),**每一对**都各跑一遍:
* ① 合规样本必须匹配得出且含两把 token ⇒ 判据不恒红;
* ② 删掉那一句的样本必须不含 ⇒ 判据能红(变异自证走的就是这一条);
@@ -521,7 +582,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
const WATCH_ACTIVE_ID = /watch\(\(\)\s*=>\s*companyTab\.activeId\s*,\s*\(\)\s*=>\s*\{([\s\S]*?)\}\s*\)/
/**
* (文件, 必须出现在 watch 体内的赋值) 九 对,同一条 test 里逐对钉(批次 1 两对 + 批次 2 五 对 + 批次 3 两对)。
* (文件, 必须出现在 watch 体内的赋值) 十 对,同一条 test 里逐对钉(批次 1 两对 + 批次 2 三 对 + 批次 3 两对 + 批次 4 一对 + 批次 5 一对 + 批次 6 一对 )。
* `premise` 是这一对的反向钉前提:这一页的发送口今天还在发 `company_id`,清筛选项才有意义;
* 哪天发送口退回不带参,watch 看守就变成"清了一个没人用的筛选项",必须一起红。
*/
@@ -551,7 +612,8 @@ const WATCH_BODY_PINS: ReadonlyArray<{
{ file : 'src/pages/task-center/task-center-model.ts' , shapes : [ /company_id\s*=\s*companyId\b/ ] } ,
] ,
} ,
// ↓ 批次 2 的五 页(控制方 2026-10-05 点名「切 tab 数据还一样」那一批)。
// ↓ 批次 2 剩下的三 页(控制方 2026-10-05 点名「切 tab 数据还一样」那一批;
// 品牌库、商品类目两页 2026-10-06 退回全平台共享,条目一并摘掉)。
// token 在两页上同形(`filter.groupId = null` 出现三次),这**不是**漏洞:判据按 (file, token) 成对求值,
// 每一对都各自去读它自己那一页的源码,别家页缺了这行不会红在这一页,反之这一页删掉了也不会被隔壁顶住
// (负样本 ③「挪到 watch 之外」钉的就是位置)。
@@ -563,14 +625,6 @@ const WATCH_BODY_PINS: ReadonlyArray<{
{ file : 'src/pages/asin/dedupe-total-api.ts' , shapes : [ /company_id\s*=\s*params\.companyId\b/ ] } ,
] ,
} ,
{
file : 'src/pages/asin/AsinInvalidPage.vue' ,
token : 'filter.groupId = null' ,
why : '品牌库的分组下拉按公司收窄,留着上一家的 groupId 就是拿一个新一家看不见的组去筛列表' ,
premise : [
{ file : 'src/pages/invalidasin/invalid-asin-api.ts' , shapes : [ /company_id\s*=\s*query\.companyId\b/ ] } ,
] ,
} ,
{
file : 'src/pages/asin/QueryAsinPage.vue' ,
token : "filter.groupId = null; filter.shopName = ''" ,
@@ -588,15 +642,6 @@ const WATCH_BODY_PINS: ReadonlyArray<{
{ file : 'src/pages/asin/skip-price-api.ts' , shapes : [ /company_id\s*=\s*params\.companyId\b/ ] } ,
] ,
} ,
{
file : 'src/pages/asin/ProductCategoryPage.vue' ,
token : 'childrenState.clear()' ,
why : '类目树是**懒加载缓存**: childrenState 里存着上一家每个父级的子页与页码,切公司不清它,展开同一父级就'
+ '直接把别家的子类目画出来(这一处根本不发请求,比"筛成空页"更静默)' ,
premise : [
{ file : 'src/pages/asin/product-category-api.ts' , shapes : [ /company_id\s*=\s*companyId\b/ ] } ,
] ,
} ,
// ↓ 批次 3 的两页(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」)。
// 这两页的 token 一直写到 reload 那两句为止(批次 1/2 的老条目仍只钉清筛选项,不动它们):
// 变异自证发现「删掉 void loadConsole()」当时全绿——清筛选项那半守住了,重新取数那半没人守。
@@ -633,6 +678,28 @@ const WATCH_BODY_PINS: ReadonlyArray<{
{ file : 'src/api/users.ts' , shapes : [ /company_id\s*=\s*params\.companyId\b/ ] } ,
] ,
} ,
// ↓ 批次 5(控制方 2026-10-06 点名「店铺密钥管理的数据按照公司区分」)。
{
file : 'src/pages/shop/ShopKeysPage.vue' ,
token : "filterKeyword.value = ''; page.value = 1; void load()" ,
why : '这一页的「备注名 / 紫鸟账号」是客户端过滤(filteredRows 在本页 rows 上筛,不进请求):'
+ '留着上一家填的关键字,切到新一家就是拿别家的字符串去筛本公司那几行 ⇒ 首屏「暂无符合条件的密钥」而筛选框里还显示着它;'
+ '页码回 1 是因为新一家的令牌更少,末尾的 void load() 才让切 tab 真的换数据' ,
premise : [
{ file : 'src/pages/shop/shop-key-api.ts' , shapes : [ /company_id\s*=\s*params\.companyId\b/ ] } ,
] ,
} ,
// ↓ 批次 6(控制方 2026-10-06 点名「菜单权限也加字段来区分」,定案「每家公司一套树」)。
{
file : 'src/pages/account/MenusPage.vue' ,
token : "filterName.value = ''; filterType.value = ''; page.value = 1; void loadMenus()" ,
why : '菜单名称/类型是客户端筛选(filteredMenuRows 在本页已取的 rows 上筛,不进请求):留着上一家填的值'
+ '就是拿别家的字符串去筛新一家那一套树 ⇒ 首屏「暂无匹配菜单」,而输入框里还显示着那个值。页码回 1 是因为'
+ '新一家的行数不同,末尾的 void loadMenus() 才是本页唯一的数据出口' ,
premise : [
{ file : 'src/pages/account/menu-manage-api.ts' , shapes : [ /company_id\s*=\s*companyId\b/ ] } ,
] ,
} ,
]
/** 取「`watch(() => companyTab.activeId, () => { … })`」这一条语句的原文;匹配不出返回 null(由调用方判探针失效)。 */
@@ -641,9 +708,9 @@ function watchStatement(source: string): string | null {
return m ? m [ 0 ] : null
}
test ( '切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 五 页 + 批次 3 两页 + 批次 4 一页)' , ( ) = > {
test ( '切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 三 页 + 批次 3 两页 + 批次 4 一页 + 批次 5 一页 + 批次 6 一页 ) ' , ( ) = > {
assert . ok ( WATCH_BODY_PINS . length >= 10 ,
` watch 体看守只剩 ${ WATCH_BODY_PINS . length } 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/品牌库/ 查询ASIN/最低价ASIN/商品类目 + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理共 10 对) `
` watch 体看守只剩 ${ WATCH_BODY_PINS . length } 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/查询ASIN/最低价ASIN + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理 + 批次 5 的店铺密钥 + 批次 6 的菜单管理 共 10 对) `
+ '⇒ 这一族又退回"只钉少数几页",被摘掉那一页的"切公司不清筛选项"再次没人看守' )
const pinnedFiles = new Set ( WATCH_BODY_PINS . map ( ( pin ) = > pin . file ) )
for ( const pin of WATCH_BODY_PINS ) {
@@ -810,3 +877,108 @@ test('挂载与单一尺子:tab 条挂在壳层、公司名读 companyName、
assert . match ( tabs , /initialize\(\)\.catch\(/ ,
'组件侧必须 .catch 接住 store 的 rethrow,否则又变回 unhandled rejection' )
} )
test ( '渲染范围:tab 条只画在按公司取数的页上,公司管理那排点了没反应的 tab 摘掉' , ( ) = > {
// 2026-10-06 控制方:「公司管理不要有 tab」。10-05 那一轮只钉住了「CompaniesPage 不消费 store」
// ( company-config-entry-super-only 最后那条),而 tab 条本身挂在壳层 AdminLayout、对全部页都画
// ⇒ 界面一个字都没变,同一天被第二次点名。这条补的是**渲染侧**那一半。
// 判据取 COMPANY_SCOPED_PAGES 这一张注册表:写黑名单的话,下一个新页默认长出一条装饰 tab。
const pageKeys = adminPages . map ( ( p ) = > p . menuKey )
assert . ok ( pageKeys . length >= 22 , ` 路由注册表只取到 ${ pageKeys . length } 页 ⇒ 分母被删空,下面的差集会假绿 ` )
const scoped = new Set ( COMPANY_SCOPED_PAGES . map ( ( p ) = > p . menuKey ) )
const unscoped = pageKeys . filter ( ( k ) = > ! scoped . has ( k ) )
assert . ok ( scoped . size >= 15 , ` 注册表只剩 ${ scoped . size } 页 ⇒ 正向那半的循环没东西可验 ` )
assert . ok ( unscoped . includes ( 'admin_companies' ) ,
'admin_companies 竟在公司 tab 注册表里:与「公司管理仅超管、不做 tab」直接冲突' )
const model = stripComments ( readSource ( 'src/layout/company-tab-model.ts' ) )
assert . match ( model , /new Set\(COMPANY_SCOPED_PAGES\.map/ ,
'companyTabAppliesTo 必须从 COMPANY_SCOPED_PAGES 派生,不是另立一张名单' )
assert . equal ( model . includes ( "'admin_companies'" ) , false ,
'渲染判据里不许写死菜单名:那是第二张清单,与注册表迟早漂移' )
// 真值双向:注册表内 ⇒ 画(漏了就是取值口与渲染口分家),注册表外每一页 ⇒ 不画(点了不重取数)
for ( const key of scoped ) assert . equal ( companyTabAppliesTo ( key ) , true , ` ${ key } 在注册表里却不画 tab ` )
for ( const key of unscoped ) assert . equal ( companyTabAppliesTo ( key ) , false , ` ${ key } 没接公司隔离却画着 tab ` )
assert . equal ( companyTabAppliesTo ( undefined ) , false , '没有 menuKey 的开放页(登录页等)默认不画' )
// 组件真把这一条串进了 show:只导出函数不接线=这条护栏恒绿
const tabs = stripComments ( readSource ( 'src/layout/CompanyTabs.vue' ) )
const showLine = tabs . split ( '\n' ) . find ( ( line ) = > line . includes ( 'const show =' ) )
assert . ok ( showLine , 'CompanyTabs.vue 找不到 `const show =` 这一行:渲染开关换写法了,先确认它还在不在' )
assert . ok ( showLine . includes ( 'tab.visibleForOperator' ) , 'show 少了「目录可用」那条' )
assert . ok ( showLine . includes ( 'companyTabAppliesTo(route.meta.menuKey)' ) ,
'show 少了「这一页吃公司」那条 ⇒ 退回全页画 tab,公司管理页头顶又会长出那一排' )
} )
/**
* 2026-10-06 控制方定案:品牌数据库、商品类目「做成所有公司共享的,不区分」。
*
* <p>上面那几条正向判据全是从 {@code COMPANY_SCOPED_PAGES} 派生的,页一退出注册表就自动不再求值 ⇒
* 「退出」这件事本身没有看守:谁把 {@code company_id} 重新塞回这三个取数口,全仓用例一支都不会红,
* 而后端唯一键已经退回全局(V151),带公司参数的读会把共享库筛窄成「只看这一家」,
* 写侧则把一张全平台共享的表按家拆开——两边都是静默改口径,不是报错。所以这一支必须存在。</p>
*
* <p>判据只认「剥完注释的代码」:这三份文件现在各自留有一句说明共享口径的注释,
* 注释里的 {@code company_id} 三个字面字符不是接线(全局约束 6)。正样本用摘掉之前那三行原文,
* 所以下面的 false 是测出来的,不是「正则本来就抓不到」。</p>
*/
const SHARED_PAGE_KEYS = [ 'admin_invalid_asin_data' , 'admin_product_categories' ] as const
const SHARED_API_FILES = [
'src/pages/invalidasin/invalid-asin-api.ts' ,
'src/pages/asin/product-category-api.ts' ,
'src/pages/asin/product-category-export.ts' ,
] as const
const SHARED_PAGE_FILES = [
'src/pages/asin/AsinInvalidPage.vue' ,
'src/pages/asin/ProductCategoryPage.vue' ,
] as const
/** 公司参数的两种写法:下传用的 snake、形参/字段用的 camel。 */
const COMPANY_PARAM_TOKEN = /(?:company_id|companyId)/
/** 本次摘掉的三行原发送口(逐字取自改动前的源码),做反向钉的同支正样本。 */
const FORMER_SEND_LINES = [
'if (query.companyId != null) params.company_id = query.companyId' ,
'if (companyId != null) params.company_id = companyId' ,
'if (companyId != null) params.push(`company_id=${companyId}`)' ,
]
test ( '公司维度不得回流:品牌库与商品类目已定案全平台共享,取数口与页面都不许再带公司参数' , ( ) = > {
// 判据自证(全局约束 15:反向钉不许独自成立)——改动前那三行必须抓得到,否则下面的 false 是空判据。
for ( const line of FORMER_SEND_LINES ) {
assert . ok ( COMPANY_PARAM_TOKEN . test ( line ) , ` 反向钉判据连原来的发送口「 ${ line } 」都匹配不出 ⇒ 这一族恒绿 ` )
}
// watch 探针同理:它今天还在 WATCH_BODY_PINS 那十对上起作用,这里再就地复验一次形状,
// 免得「页面里没有 watch」是因为正则换了写法而失明。
assert . ok ( WATCH_ACTIVE_ID . test ( 'watch(() => companyTab.activeId, () => { void load() })' ) ,
'WATCH_ACTIVE_ID 连合规样本都匹配不出 ⇒ 下面「不许再长出 watch」那条恒绿' )
// 注册表本身非空自证:表被删空时 some() 会对所有 key 返回 false,看着像「都退出了」。
assert . ok ( COMPANY_SCOPED_PAGES . length >= 15 ,
` 注册表只剩 ${ COMPANY_SCOPED_PAGES . length } 页 ⇒ 分母被删空,下面的 some() 会假绿 ` )
for ( const key of SHARED_PAGE_KEYS ) {
assert . equal ( COMPANY_SCOPED_PAGES . some ( ( p ) = > p . menuKey === key ) , false ,
` ${ key } 又回到 COMPANY_SCOPED_PAGES: 2026-10-06 已定案这两页全平台共享,不区分公司 ` )
const page = adminPages . find ( ( p ) = > p . menuKey === key )
assert . ok ( page , ` ${ key } 在路由注册表里找不到:菜单名改了,反向钉对不上页 ` )
assert . equal ( page . companyScoped , false ,
` ${ key } 的 meta.companyScoped 不再是 false:tab 条会画出来,而这一页的取数口没有公司参数 ⇒ 点了没反应) ` )
}
for ( const file of [ . . . SHARED_API_FILES , . . . SHARED_PAGE_FILES ] ) {
const src = stripComments ( read ( file ) )
assert . equal ( COMPANY_PARAM_TOKEN . test ( src ) , false ,
` ${ file } 又出现了公司参数:这两页读的是全平台共享的库,带上 company_id 等于把共享口径偷偷改回按家筛 ` )
assert . ok ( COMPANY_PARAM_TOKEN . test ( ` ${ src } \ n ${ FORMER_SEND_LINES [ 0 ] } ` ) ,
` (同支正样本) ${ file } 的源码喂进判据后连拼上原发送口都匹配不出 ⇒ 上面那条 false 无从判定 ` )
}
for ( const file of SHARED_PAGE_FILES ) {
const src = stripComments ( read ( file ) )
assert . equal ( WATCH_ACTIVE_ID . test ( src ) , false ,
` ${ file } 又 watch 了 companyTab.activeId:这一页不按公司取数,切 tab 重取数只会把用户正在看的页刷掉 ` )
assert . equal ( /useCompanyTabStore|companyTab\.requestCompanyId/ . test ( src ) , false ,
` ${ file } 重新引回了公司 tab store,而它对应的 tab 条已经摘掉 ` )
}
} )