@@ -41,42 +41,100 @@ const TASK_CENTER_SEND_LINE = 'if (companyId != null) query.company_id = company
* - 从 `function` 这个词的头起算(旧举证用的口径,比上组各多 33~36):154/147/196/238/244 与 471/726/(无)/877/(无)。
* ⇒ 320 够得着自己的行(最紧 217),够不到隔壁(最紧 438,余量 **118 字符**):删掉任一处,那条 shape 就匹配不出
* (不是"文件里还有别人在发"就算过)。
* ⚠ 下面那段「拆条取样自检·负样本」只证明「窗口有界」,它跟着 `TASK_CENTER_WINDOW` 自动缩放 ⇒ **证明不了余量还在**。
* ⚠ 下面那段「拆条取样自检·负样本」只证明「窗口有界」,它跟着窗口预算 自动缩放 ⇒ **证明不了余量还在**。
* 把 320 调大之前必须按第一组口径重测这五个数;api 函数体写长会先假红(fail-closed,可接受)。
* 批次 2 起这一档改成 `SendPoint.window`(每处一个值),举证不再靠这段注释,
* 而由「窗口与真文件对平」那条用例逐处重测 own/next。
*/
const TASK_CENTER_WINDOW = 320
/** 一个登记项 = 一个字面发送口(一函数一处、逐处一条,一条都不许并)。 */
interface SendPoint {
readonly menuKey : string
readonly file : string
/** 这一处所在函数的名字:shape 锚在 `function <fn>(` 的括号后,红点直接报到函数。 */
readonly fn : string
/** 塞键那一整行(缩进不入锚串)。整行入锚而不只锚 `company_id = companyId`:
* 评审把 `params.companyId` 改成 `normalized.companyId` 时形状判据(复评 I-2)要能红,
* 锚右半边的字面量才是举证。 */
readonly line : string
/** 从 `function <fn>(` 括号后到自己那一行的字符预算,见上面 TASK_CENTER_WINDOW 的注释。 */
readonly window : number
readonly title : string
}
/** 正则字面量转义:`line` 里带 `( ) . = { } $ [ ]` 与反引号,不转义就匹配到别处(sendArgsShape 同一把尺子)。 */
function escapeRegExp ( text : string ) : string {
return text . replace ( /[.*+?^${}()|[\]\\]/g , '\\$&' )
}
/**
* 这一页的 5 处 `company_id` 发送口(2026-10-05 修复轮 1,复评 I-1)。
* 全部 22 个字面发送口:批次 1 的任务看板 5 处 + 批次 2(控制方 2026-10-05 点名「切 tab 数据还一样」那五页)12 处
* + 批次 3(控制方 2026-10-05 点名「店铺撞款监控 店铺数据也要做隔离」那两页)4 处
* + 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」里的用户管理)1 处。
*
* <p>为什么从 2 条文件级钉拆成 5 条:`shape` 的求值是整文件 `RegExp.test`(不数次数),
* 评审实测「删掉 5 处里的任何一处」在两条文件级钉下**双双仍为 true**——包括 brief
* `task-10-brief.md:14` 点名的那一处(`fetchTaskCenterTaskDetail` 少带参数 ⇒ 超管在别家 tab 下按
* taskNo 读别家详情照样 200,这一页的护栏恰好全落在前端)。`vue-tsc` 也救不了:tsconfig 没开
* `noUnusedParameters`,删了塞键那一行、留一个没人用的形参,编译器不响。</p>
* <p>`window` 的取法:本轮实扫的 own(到自己那行的距离)+ ≥150 余量,且当同文件还有下一个同名发送口时必须
* `window < next`。own/next 不写死在这里——下面「窗口与真文件对平」那条用例逐处从真文件重算,
* `own >= window`(函数体写长)或 `window >= next`(窗口够到隔壁)都当场红。</p>
*
* <p>选「拆条」而不是「计数」(`occurrences()` 数 api=3 / model=2):计数不回答「哪三处」 ,
* 把一处重复写三遍、另一处删掉,计数照样绿;函数名锚 + 有界窗口才把判据绑到发送口自己的身份上。
* 形状照 `admin_shop_manage` 的先例(同一个文件两条 pin,「两条各管一处取值口,不许合成一条 alternation」) 。</p>
* <p>三个 `*-export.ts` 的 own 天生比 api 侧大(构造器是多行签名 + 一串前置筛选条件:625/528/827) ,
* 它们的 `line` 在同文件只出现 1 次(对平闸门数得出),所以"窗口会不会够到隔壁"在这一族是空命题,
* 真正的看守是「这一处脱管就没人钉」 。</p>
*
* <p>`shape` 与取样样本同源于这张表(都由 fn/window 现算),不会出现「钉改了、自检还测旧串」的漂移。</p>
* <p>批次 3 的撞款控制台三个发送口把塞键行的左值各起一个名字(query / params / itemsQuery):
* 三处若逐字同行,(文件, 整行) 分组会把它们并成一组、要求钉 3 条,而「窗口够不到隔壁」这条判据
* 在同一行重复时才有意义——左值不同名既是真代码的样子,也让每条钉各自点到唯一一个发送口。</p>
*/
const TASK_CENTER_SEND_POINTS : ReadonlyArray < { readonly file : string ; readonly fn : string ; readonly title : string } > = [
{ file : 'src/api/task-center.ts' , fn : 'fetchTaskCenterOverview' , title : 'GET /overview 汇总卡' } ,
{ file : 'src/api/task-center.ts' , fn : 'fetchTaskCenterShopOptions' , title : 'GET /shop-options 店铺候选' } ,
{ file : 'src/api/task-center.ts' , fn : 'fetchTaskCenterTaskDetail' , title : 'GET /tasks/detail 详情(brief 点名那一处)' } ,
{ file : 'src/pages/task-center/task-center-model.ts' , fn : 'buildTaskQuery' , title : '任务列表 query 构造器' } ,
{ file : 'src/pages/task-center/task-center-model.ts' , fn : 'buildVariantQuery' , title : '变体采集 query 构造器' } ,
const SEND_POINTS : ReadonlyArray < SendPoint > = [
{ menuKey : 'admin_task_center' , file : 'src/api/task-center.ts' , fn : 'fetchTaskCenterOverview' , line : TASK_CENTER_SEND_LINE , window : TASK_CENTER_WINDOW , title : 'GET /overview 汇总卡' } ,
{ menuKey : 'admin_task_center' , file : 'src/api/task-center.ts' , fn : 'fetchTaskCenterShopOptions' , line : TASK_CENTER_SEND_LINE , window : TASK_CENTER_WINDOW , title : 'GET /shop-options 店铺候选' } ,
{ menuKey : 'admin_task_center' , file : 'src/api/task-center.ts' , fn : 'fetchTaskCenterTaskDetail' , line : TASK_CENTER_SEND_LINE , window : TASK_CENTER_WINDOW , title : 'GET /tasks/detail 详情(brief 点名那一处)' } ,
{ menuKey : 'admin_task_center' , file : 'src/pages/task-center/task-center-model.ts' , fn : 'buildTaskQuery' , line : TASK_CENTER_SEND_LINE , window : TASK_CENTER_WINDOW , title : '任务列表 query 构造器' } ,
{ menuKey : 'admin_task_center' , file : 'src/pages/task-center/task-center-model.ts' , fn : 'buildVariantQuery' , line : TASK_CENTER_SEND_LINE , window : TASK_CENTER_WINDOW , title : '变体采集 query 构造器' } ,
{ 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 指标/店铺/撞款全集/分组统计' } ,
{ menuKey : 'admin_shop_data_duplicate_check' , file : 'src/pages/tasks/duplicate-console-api.ts' , fn : 'fetchDuplicateLedger' , line : 'if (companyId != null) params.company_id = companyId' , window : 400 , title : 'GET /duplicate-check-ledger 全部 ASIN 台账分页' } ,
{ menuKey : 'admin_shop_data_duplicate_check' , file : 'src/pages/tasks/duplicate-console-api.ts' , fn : 'requestDuplicateExportBlob' , line : 'if (companyId != null) itemsQuery.company_id = companyId' , window : 400 , title : 'GET /duplicate-check-export 导出(不带就导全平台)' } ,
{ 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 用户列表(后端早就认这个参数,断的是前端没发)' } ,
]
/** 一个发送口一条钉:锚在自己的函数开行上,要求窗口内出现「塞键」那一行 。 */
function sendPointShape ( fn : string ) : RegExp {
return new RegExp ( ` function ${ fn } \\ ([ \\ s \\ S]{0, ${ TASK_CENTER_WINDOW } }company_id \\ s*= \\ s*companyId \\ b ` )
/** 任务看板那 5 处(1b ④ 那条用例按文件筛它们,沿用旧名字不漂;表只有一份,不会漂出两个口径) 。 */
const TASK_CENTER_SEND_POINTS : ReadonlyArray < SendPoint > =
SEND_POINTS . filter ( ( p ) = > p . menuKey === 'admin_task_center' )
/** 一条钉 = 一个发送口:锚在自己的函数开行上,要求窗口内出现「塞键」那一整行。 */
function pointShape ( p : SendPoint ) : RegExp {
return new RegExp ( ` function ${ p . fn } \\ ([ \\ s \\ S]{0, ${ p . window } } ${ escapeRegExp ( p . line ) } ` )
}
/** 正样本用的迷你源码:函数开行 + 它自己那行塞键(缩进、形状逐字照抄真实发送口)。 */
function sendPointCompliant ( fn : string ) : string {
return ` function ${ fn } (companyId?: number | null) { \ n const query: QueryParams = {} \ n ${ TASK_CENTER_SEND_LINE } \ n `
function pointCompliant ( p : SendPoint ) : string {
return ` function ${ p . fn } (companyId?: number | null) { \ n const query: QueryParams = {} \ n ${ p . line } \ n `
}
/** 同一页的取值口钉由 SEND_POINTS 现算,不许手写:手写会和表漂开(复评 I-1 拆条的初衷)。 */
function pinsFor ( menuKey : string ) : readonly CompanyIdPin [ ] {
return SEND_POINTS . filter ( ( p ) = > p . menuKey === menuKey ) . map ( ( p ) = > ( {
file : p.file ,
shape : pointShape ( p ) ,
note : ` 发送口 ${ p . fn } ( ${ p . title } ):company_id 的右半边必须是本函数自己的入参(表里登记的整行锚), `
+ '值由页面传 companyTab.requestCompanyId;红点归属见「窗口与真文件对平」那条用例' ,
} ) )
}
const COMPANY_ID_SOURCE_PINS : Readonly < Record < string , readonly CompanyIdPin [ ] > > = {
@@ -97,16 +155,10 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
note : 'filter 走 toImageVideoQuery 白名单构造,公司值只能落在 companyId 形参上' ,
} ,
] ,
// 五个发送口五条钉(一函数一条),不是一条文件级钉数五处:判据形状见 TASK_CENTER_ SEND_POINTS 的举证。
// 五个发送口五条钉(一函数一条),不是一条文件级钉数五处:判据形状见 SEND_POINTS 的举证。
// 这一页也不许套 Task 8 的 `params.companyId` 形——api 侧 `tasks`/`variant-tasks` 是 `params: QueryParams`
// 直传、没有 params.companyId 这个口,公司键由 model 那两个 builder 补进同一个对象。
admin_task_center : TASK_CENTER_SEND_POINTS.map ( ( p , i ) = > ( {
file : p.file ,
shape : sendPointShape ( p . fn ) ,
note : ` 发送口 ${ i + 1 } /5 ${ p . title } ( ${ p . fn } ):null 由发送口自己丢(不依赖 axios 丢 null), `
+ '右半边必须是本函数自己的形参 companyId;红点归属见下面「拆条的补集」那段——删掉塞键那一行报在对平闸门,'
+ '这条 shape 独家点名的是计数不掉的形变(函数名改了、或那一行离自己函数开行超过了窗口)' ,
} ) ) ,
admin_task_center : pinsFor ( 'admin_task_center' ) ,
admin_user_secret_usage : [
{
file : 'src/api/user-secret-usage.ts' ,
@@ -154,6 +206,17 @@ const COMPANY_ID_SOURCE_PINS: Readonly<Record<string, readonly CompanyIdPin[]>>
note : '列表窄了而下拉不窄 = 两页口径对不上,且下拉能选到别家的组' ,
} ,
] ,
// 批次 2 的五页:取值口钉全部由 SEND_POINTS 现算(一页几处发送口就几条钉),
// 手写一份就会和表漂开——那正是复评 I-1 拆条要避免的形状。
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' ) ,
}
/** 严格判据的分母由本轮实扫得出(修完不许恒绿也不许恒红):求值了几条 shape、其中几条通过。 */
@@ -236,29 +299,28 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
&& COMPANY_ID_SOURCE_PINS . admin_image_video_tasks . some ( ( p ) = > p . shape !== null ) ,
'Task 8 已接线的两页在登记表里的 shape 被改回 null 了:严格判据对这两页不再起作用(正样本归零)' )
// —— I-1 拆条那 5 条钉的取样自检(全局约束 15:反向钉必须自带同支正样本,
// —— 取值口拆 条钉的取样自检(全局约束 15:反向钉必须自带同支正样本,
// 不许让另一支用例替我证明"这串本来就会被匹配到")。
// ⚠ 身份要说清:下面这几条是对**字面量字符串**求值的探针,只证明判据形状没写坏
// (正样本匹配得出 ⇒ 不恒红;窗口外的负样本不匹配 ⇒ 窗口真有界,删一处不会靠隔壁过关),
// 任何代码注入都不会让它们红。真覆盖 = 上面 loop 里那 5 条 shape 对真实文件的求值 + 变异自证。
// ⚠ 这条 length 比对**按构造恒真**( 2026-10-05 复评 N-2):登记表条目就是 `TASK_CENTER_SEND_POINTS.map(...)` ,
// 删表一行两边同时变成 4,它一声不响。它只剩一种防御对象——有人把那个 `.map()` 换成手写 N 条字面 pin;
// 「删表一行」的真红点在下面「拆条的补集」那条逐文件对平闸门(它的分母取自源码里的字面发送口,与表不同源)。
assert . equal ( COMPANY_ID_SOURCE_PINS . admin_task_center . length , TASK_CENTER_SEND_POINTS . length ,
` 登记表条数与 TASK_CENTER_SEND_POINTS 条数不等 ⇒ 上面那条 .map() 被换成了手写 pin 且数量不符 `
+ ` (表 ${ TASK_CENTER_SEND_POINTS . length } 条 / 登记表 ${ COMPANY_ID_SOURCE_PINS . admin_task_center . length } 条) ` )
for ( const p of TASK_CENTER_SEND_POINTS ) {
const shape = sendPointShape ( p . fn )
const compliant = sendPointCompliant ( p . fn )
// 任何代码注入都不会让它们红。真覆盖 = 上面 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 条)⇒ 有人把钉从表里摘了,取值口看守成空 ` )
for ( const p of SEND_POINTS ) {
const shape = pointShape ( p )
const compliant = pointCompliant ( p )
assert . ok ( shape . test ( compliant ) ,
` (拆条取样自检·正样本) ${ p . fn } 的合规样本都匹配不出 ${ shape } ⇒ 这条钉恒红,删没删发送口都会红,等于没看守 ` )
const deleted = compliant . replace ( ` ${ TASK_CENTER_SEND_LINE } \ n ` , '' )
+ ' ' . repeat ( TASK_CENTER_WINDOW + 1 ) + TASK_CENTER_SEND_LINE
const deleted = compliant . replace ( ` ${ p . line } \ n ` , '' )
+ ' ' . repeat ( p . window + 1 ) + p . line
assert . equal ( shape . test ( deleted ) , false ,
` (拆条取样自检·负样本) ${ p . fn } 删掉自己那一行、只剩窗口外的隔壁发送口却仍然匹配 ⇒ 窗口够得到了隔壁,删一处不会红 ` )
}
// 拆条的补集(复评 I-1 的另一半):一条钉管一个发送口 ⇒ 每个文件登记的钉数必须等于该文件里发送口的实际条数。
// 拆条的补集(复评 I-1 的另一半):一条钉管一个发送口 ⇒ 每个 (文件, 塞键整行) 登记的钉数
// 必须等于它在该文件的实际条数。
// 红点归属要说实(2026-10-05 复评 N-1):shape 不匹配只往 gaps 里记,得等本用例末尾的
// `assert.deepEqual(problems, [])` 才喊,而这条闸门在同一 test 体内**先执行** ⇒
// 「删源码里的塞键那一行」(变异自证 M1–M5 就是这一形)实际报的是这里的「钉数 ≠ 实际条数」消息
@@ -268,21 +330,65 @@ test('正向:声明 companyScoped 的页,其 api 文件必须真的带 company
// 这一条杀的是「把 TASK_CENTER_SEND_POINTS 删剩 4 行」——少一条钉就等于少一处看守,而 5 条 shape 谁都不会红。
// 路线 ②(occurrences 计数)在这里只当"钉数与发送口条数对平"的闸门,不当"是哪一处"的判据:
// 计数回答不了"哪三处"(把一处重复写三遍、另一处删掉,计数照样对平),所以主判据仍是路线 ① 的函数名锚 + 有界窗口。
const pinnedPerFile = new Map < string , number > ( )
for ( const p of TASK_CENTER_SEND_POINTS ) {
pinnedPerFile . set ( p . file , ( pinnedPerFile . get ( p . file ) ? ? 0 ) + 1 )
// 分母按 (文件, 整行) 而不是按文件:批次 2 的 product-category-api.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 ) {
const key = p . file + '|' + p . line
const hit = grouped . get ( key )
if ( hit ) hit . pinned += 1
else grouped . set ( key , { file : p.file , line : p.line , pinned : 1 } )
}
assert . equal ( pinnedPerFile . size , 2 ,
` 发送口表应当只覆盖 api + model 这 2 个文件 ,现在却有 ${ pinnedPerFile . size } 个 —— 表被改形状了,对平判据失去分母 ` )
for ( const [ file , pinned ] of pinnedPerFile ) {
const actual = occurrences ( stripComments ( read ( file ) ) , TASK_CENTER_SEND_LINE )
assert . equal ( pinned , actual ,
` ${ file } 里实际有 ${ actual } 处「 ${ TASK_CENTER_SEND_LINE } 」,登记表却只钉了 ${ pinned } 条 —— `
+ '有一处发送口脱管(一函数一钉:钉数必须与该文件的发送口条数逐文件 对平)' )
assert . equal ( grouped . size , 17 ,
` 发送口表按 (文件, 整行) 应聚成 17 组(22 处发送口) ,现在却有 ${ grouped . size } 组 —— 表被改形状了,对平判据失去分母 ` )
for ( const g of grouped . values ( ) ) {
const actual = occurrences ( stripComments ( read ( g . file ) ) , g . line )
assert . equal ( g . pinned , actual ,
` ${ g . file } 里实际有 ${ actual } 处「 ${ g . line } 」,登记表却只钉了 ${ g . pinned } 条 —— `
+ '有一处发送口脱管(一函数一钉:钉数必须与该文件该行的实际条数 对平)' )
}
// 同支正样本(全局约束 15:计数判据不许"0 == 0 也算对平"就当自己成立):字面样本里有两条,occurrences 必须数得出 2。
assert . equal ( occurrences ( sendPointCompliant ( 'f' ) + sendPointCompliant ( 'g' ) , TASK_CENTER_SEND_LINE ) , 2 ,
'(计数取样自检·正样本)occurrences 连两条字面发送口都数不出来 ⇒ 上面那条逐文件对平恒真,等于没看守' )
const twoSendLines = ` function f() { \ n ${ TASK_CENTER_SEND_LINE } \ n} \ nfunction g() { \ n ${ TASK_CENTER_SEND_LINE } \ n} \ n `
assert . equal ( occurrences ( twoSendLines , TASK_CENTER_SEND_LINE ) , 2 ,
'(计数取样自检·正样本)occurrences 连两条字面发送口都数不出来 ⇒ 上面那条逐行对平恒真,等于没看守' )
// 窗口预算与真文件对平:批次 2 把上面 TASK_CENTER_WINDOW 那段"320 够得着自己、够不到隔壁"的举证从注释挪进代码,
// 逐处从**当前源码**重算两个距离,注释过期也不会骗人:
// own = 从 `function <fn>(` 的括号后到自己那一行的距离 ⇒ 必须 < window(函数体写长 = 假红,fail-closed 可接受);
// next = 到同文件**下一条同名发送行**开头的距离 ⇒ 存在时必须 > window(否则删一处还有隔壁顶着,这条钉就是摆设)。
// 隔壁的"名字"用的是自己的整行,所以 next 只在同文件有逐字同行的另一处时才有意义:
// product-category-api.ts 三处同行(next 实测 705/929/无)是这一族唯一的真冲突面,其余 14 处 own 唯一。
for ( const p of SEND_POINTS ) {
const src = stripComments ( read ( p . file ) )
const anchor = 'function ' + p . fn + '('
const anchorCount = occurrences ( src , anchor )
assert . equal ( anchorCount , 1 ,
` ${ p . file } 里「 ${ anchor } 」出现 ${ anchorCount } 次(要求 1):函数改名或被复制,这条按函数名钉的看守就对不上是谁发的 ` )
const open = src . indexOf ( anchor ) + anchor . length
const own = src . indexOf ( p . line , open ) - open
assert . ok ( own >= 0 && own < p . window ,
` ${ p . fn } 的塞键行离自己函数开行 ${ own } 字符,窗口预算却是 ${ p . window } :own<0 = 那一行整段没了或换了写法; `
+ 'own>=window = 函数体写长把这一处挤出了窗口(这条判据宁可假红也不放宽,放宽就等于够得着隔壁)' )
const second = src . indexOf ( p . line , src . indexOf ( p . line , open ) + p . line . length )
assert . ok ( second < 0 || p . window < second - open ,
` ${ p . fn } 的窗口( ${ p . window } )够得着同文件下一条同名发送口(距离 ${ second - open } ): `
+ '删掉这一处,隔壁那行会替它过关,这条钉就只守得住"两处一起删"' )
}
// 覆盖性自检的另一半:清单里每个 api 文件,只要它已经把 company_id 当参数下传,就必须被**点名到文件**的钉盖住。
// 上面 loop 的 shape 只求值"登记了的那条钉指向的文件",而正向的 `/company_id\s*[:=]/` 问的是整个文件——
// 于是"给某页的 apiFiles 新增一个会发 company_id 的模块、却不给它登记取值口钉"这一手能双双过关
// (新模块的宽松判据绿、旧模块的严格判据也绿)。批次 2 的 dedupe/query/skip-price 三页各有 2 个发送文件,正是这一形。
for ( const page of COMPANY_SCOPED_PAGES ) {
const pinnedFiles = new Set ( ( COMPANY_ID_SOURCE_PINS [ page . menuKey ] ? ? [ ] ) . map ( ( p ) = > p . file ) )
for ( const file of page . apiFiles ) {
const wired = /company_id\s*[:=]/ . test ( stripComments ( read ( file ) ) )
if ( wired && ! pinnedFiles . has ( file ) ) {
problems . push ( ` ${ page . menuKey } : ${ file } 已经在下传 company_id,登记表里却没有一条钉指向它 `
+ '——正向只问"文件里有没有",那是恒绿的宽松档' )
}
}
}
assert . deepEqual ( problems , [ ] ,
` 公司 tab 接线缺口(逐页列全;批次 1 的 8 页到 Task 10 已全部接线,谁再退回未接线就红在这里): \ n `
@@ -400,7 +506,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
* 症状回到裁决 1 想避免的那一型。</p>
*
* <p>判据形状:从 `watch(() => companyTab.activeId, …)` 那**一条语句**取文本(正则在第一个
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;两 页今天都没有那种写法,由下面的取样自检兜着)。
* `}` + `)` 处收口 ⇒ 单层,体内再嵌对象字面量会截早;表里这九 页今天都没有那种写法,由下面的取样自检兜着)。
* 反向钉与正样本同支(全局约束 15,三条前提不成立就是探针失效、当场红,不许静默空跑),**每一对**都各跑一遍:
* ① 合规样本必须匹配得出且含两把 token ⇒ 判据不恒红;
* ② 删掉那一句的样本必须不含 ⇒ 判据能红(变异自证走的就是这一条);
@@ -415,7 +521,7 @@ test('反向:把 company_id 当查询参数用的取数模块必须被清单
const WATCH_ACTIVE_ID = /watch\(\(\)\s*=>\s*companyTab\.activeId\s*,\s*\(\)\s*=>\s*\{([\s\S]*?)\}\s*\)/
/**
* (文件, 必须出现在 watch 体内的赋值) 两 对,同一条 test 里逐对钉。
* (文件, 必须出现在 watch 体内的赋值) 九 对,同一条 test 里逐对钉(批次 1 两对 + 批次 2 五对 + 批次 3 两对) 。
* `premise` 是这一对的反向钉前提:这一页的发送口今天还在发 `company_id`,清筛选项才有意义;
* 哪天发送口退回不带参,watch 看守就变成"清了一个没人用的筛选项",必须一起红。
*/
@@ -445,6 +551,88 @@ 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 数据还一样」那一批)。
// token 在两页上同形(`filter.groupId = null` 出现三次),这**不是**漏洞:判据按 (file, token) 成对求值,
// 每一对都各自去读它自己那一页的源码,别家页缺了这行不会红在这一页,反之这一页删掉了也不会被隔壁顶住
// (负样本 ③「挪到 watch 之外」钉的就是位置)。
{
file : 'src/pages/asin/DedupeRegistryPage.vue' ,
token : 'filter.groupId = null' ,
why : '分组候选 /shop-manages/groups 现在按公司下传,上一家选中的 groupId 在新一家的字典里不存在 ⇒ 去重库被它筛成空页' ,
premise : [
{ 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 = ''" ,
why : '这一页的店铺名候选是按分组现拉的(fetchShopNamesByGroup 也透传了公司):只清 groupId 而留着 shopName, '
+ '新一家会被一个不属于它的店铺名筛空,而筛选项 UI 上还显示着上一家填的值' ,
premise : [
{ file : 'src/pages/asin/query-asin-api.ts' , shapes : [ /company_id\s*=\s*params\.companyId\b/ ] } ,
] ,
} ,
{
file : 'src/pages/asin/SkipPricePage.vue' ,
token : "filter.groupId = null; filter.shopName = ''" ,
why : '同查询 ASIN 页:分组与店铺名是一对(店铺名候选跟着分组走),切公司必须一起清' ,
premise : [
{ 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()」当时全绿——清筛选项那半守住了,重新取数那半没人守。
{
file : 'src/pages/tasks/DuplicateCheckPage.vue' ,
token : "filter.shop = ''; filter.group = ''; selectedGroup.value = ''; scope.value = 'global'; void loadConsole(); void loadLedger(1)" ,
why : '这一页的店铺下拉与分组下拉的候选字典都由 /duplicate-check-console 按公司下发(shops/groups 都来自裁剪后的可见集),'
+ '留着上一家选中的店铺名/分组名,新一家首屏就被一个不属于它的值筛成空页;selectedGroup 单独清是因为'
+ ' loadConsole 的重挑分支只在 groupStats 非空时触发,切到没有分组的公司时它会原样留着。'
+ '末尾两句是 reload:清完了却不重取,页面还是上一家的快照' ,
premise : [
{ file : 'src/pages/tasks/duplicate-console-api.ts' , shapes : [ /company_id\s*=\s*companyId\b/ ] } ,
] ,
} ,
{
file : 'src/pages/tasks/ShopDataTasksPage.vue' ,
token : "filter.shopName = ''; filter.groupName = ''; selection.value = createShopDataSelection(); page.value = 1; cardPage.value = 1; void load()" ,
why : '两处自由文本筛选项留着上一家填的值 = 拿新一家看不见的店铺名去筛列表;勾选集更硬——它存的是 resultId, '
+ '跨公司不清的话点「批量下载」会把别家店铺的结果文件打进同一个 zip(不发筛选请求,直接按 id 取件);'
+ '页码回 1 是因为新一家的条数更少,末尾的 void load() 才让切 tab 真的换数据' ,
premise : [
{ file : 'src/pages/tasks/shop-data-api.ts' , shapes : [ /company_id\s*=\s*companyId\b/ ] } ,
] ,
} ,
// ↓ 批次 4(控制方 2026-10-05 点名「菜单权限和用户管理也要区分公司 tab 的数据」)。
{
file : 'src/pages/account/UsersPage.vue' ,
token : "filters.createdByAdminId = null; filters.keyword = ''; filters.page = 1; void loadUsers()" ,
why : '「所属管理员」的候选 admins 随本公司的列表响应给出,上一家的 adminId 在新一家的下拉里不存在;'
+ '用户名又全平台唯一(V143 的唯一索引),留着上一家填的关键字去筛新一家必然空页,'
+ '而输入框还显示着那个值——两处都不是后端筛坏了。末尾的 void loadUsers() 是本页唯一的数据出口,'
+ '少了它前面三条赋值都只是清了一遍没人看的表单' ,
premise : [
{ file : 'src/api/users.ts' , shapes : [ /company_id\s*=\s*params\.companyId\b/ ] } ,
] ,
} ,
]
/** 取「`watch(() => companyTab.activeId, () => { … })`」这一条语句的原文;匹配不出返回 null(由调用方判探针失效)。 */
@@ -453,9 +641,10 @@ function watchStatement(source: string): string | null {
return m ? m [ 0 ] : null
}
test ( '切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(店铺管理清 groupId、任务看板清 shop ) ' , ( ) = > {
assert . ok ( WATCH_BODY_PINS . length >= 2 ,
' watch 体看守被删到只剩一对 ⇒ 这一族又退回"只钉 ShopManagePage",任务看板那行 filter.shop 再次没人看守' )
test ( '切公司的 watch 体:每对 (file, token) 都要在该页 watch 体内出现(批次 1 两页 + 批次 2 五页 + 批次 3 两页 + 批次 4 一页 ) ' , ( ) = > {
assert . ok ( WATCH_BODY_PINS . length >= 10 ,
` watch 体看守只剩 ${ WATCH_BODY_PINS . length } 对(批次 1 的店铺管理/任务看板 + 批次 2 的去重库/品牌库/查询ASIN/最低价ASIN/商品类目 + 批次 3 的撞款监控/店铺数据记录 + 批次 4 的用户管理共 10 对) `
+ '⇒ 这一族又退回"只钉少数几页",被摘掉那一页的"切公司不清筛选项"再次没人看守' )
const pinnedFiles = new Set ( WATCH_BODY_PINS . map ( ( pin ) = > pin . file ) )
for ( const pin of WATCH_BODY_PINS ) {
// ① 正样本(判据不恒红)——逐字就是这一页今天 watch 体里的那一行。