Merge PR #112: 藏書地圖看得到自己的知識——租戶字串改從寫入端來(Arcrun#108)
總管複驗(不聽自述,自己重跑並與 base 逐條比對):
cypher 14 failed / 441 passed(base 14 / 400)⇒ 多 41 條新測試全過
失敗清單 diff 無輸出=逐字元相同、零回歸
閘實測 照 #105/#108 的原句形狀種一個違規(env.CONSOLE_TENANT || leo)
→ 掃描器當場抓到並指名道姓;移除後恢復綠 ⇒ 不是假綠
這道閘的價值超過本票:它擋的是「身分來自環境變數」整族,
#105 那句話今天再寫一次也會被擋。符合 leo 08-12 立的
「做平台要減少 hotfix」——修掉 bug 不算完成,要留下下次再犯會被擋住的機制。
agent 誠實標的殘項(不擋併):
· kbdb_get_map 回 1851、Portal 總圖畫面、部分授權帳號實測——都要部署 leo21c,紅線沒碰
· 想把閘也接進 .claude/hooks/pre-write-guard.sh(寫入前就擋),該檔受保護改不動;
檢查器已備妥 --stdin 模式,總管代接
This commit was merged in pull request #112.
This commit is contained in:
@@ -42,6 +42,8 @@ import { join, resolve, basename, relative } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { execSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
// Arcrun#108 出貨閘(見 main() 內註解)。規則本體與掃描器住在 cypher-executor/scripts/。
|
||||
import { scanProject as scanTenantSources } from '../cypher-executor/scripts/check-tenant-source.mjs';
|
||||
|
||||
// REPO 一律用「本檔自己的位置」推導,不吃 cwd/env——這是踩坑①解法的地基:
|
||||
// 不管這個 clone 被放在磁碟哪個絕對路徑,REPO 永遠是「這個 repo 的根目錄」,
|
||||
@@ -214,6 +216,29 @@ async function main() {
|
||||
console.log('✔ node_modules 檢查通過:');
|
||||
for (const p of precheck) console.log(` ${p.w.dir} (${p.chk.via})`);
|
||||
|
||||
// ── 出貨閘:靜態租戶字串不得用於資料面過濾(Arcrun#108,#105 同族)─────────────
|
||||
//
|
||||
// 為什麼擋在**這裡**:這條路徑是成品的產地(.worker-builds/ → 使用者的機器)。
|
||||
// 擋在這裡=違規的碼**編不出成品、出不了貨**,而不是「有人記得跑檢查才會發現」。
|
||||
// leo 2026-08-12:「做一個平台要減少 hotfix。」規則存在但沒機制驗證,就是會再犯第三次。
|
||||
//
|
||||
// 規則本體是純函式(cypher-executor/scripts/tenant-source-rules.mjs),
|
||||
// 由 cypher-executor/tests/tenant-gate.test.ts 逐條驗「壞例子會擋、合法寫法零誤攔」
|
||||
// ——這道閘自己可測,也擋不到自己(掃描範圍只有 cypher-executor/src/)。
|
||||
const tenantViolations = scanTenantSources(join(REPO, 'cypher-executor'));
|
||||
if (tenantViolations.length) {
|
||||
console.error('\n❌ 建置中止:cypher-executor 有「靜態租戶字串用於資料面過濾」的寫法(Arcrun#108 的閘):\n');
|
||||
for (const v of tenantViolations) {
|
||||
console.error(` [${v.rule}] ${v.file}:${v.line} ${v.text}`);
|
||||
console.error(` → ${v.message}`);
|
||||
}
|
||||
console.error('\n知識資料面請用 knowledgeOwner(env) + ownerQuery()/ownerField()');
|
||||
console.error('(cypher-executor/src/lib/tenant.ts 是租戶字串的唯一產地)。');
|
||||
console.error('本機自查:cd cypher-executor && npm run check:tenant\n');
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('✔ 租戶來源檢查通過:cypher-executor 資料面 owner_id 全部來自 src/lib/tenant.ts');
|
||||
|
||||
if (CHECK_ONLY) {
|
||||
console.log('\n--check-only:只驗證依賴就緒,不編譯。');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user