From d87ae4a65fe2d9cf0e7e6caba63f6e126d451be3 Mon Sep 17 00:00:00 2001 From: Danyang Chen Date: Fri, 27 Nov 2026 14:03:58 +0800 Subject: [PATCH 1/2] ci: read the exec-family patterns on product code only (#3393) `diffPatterns` was read on every code file, so a test fixture that spawns or evaluates was called T3: #3382 was T3 for `new Function(` under runtime/flybot/plugins/social/test/. Move the five exec-family patterns to `diffPatternsNotInTests`, which is read on product code only; `.only(`/`.skip(` and the lint suppressions stay in `diffPatterns`, because in a test file they still mean something. Related #3393 --- .github/agent/risk-rules.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/agent/risk-rules.json b/.github/agent/risk-rules.json index 114599227..8edeea704 100644 --- a/.github/agent/risk-rules.json +++ b/.github/agent/risk-rules.json @@ -28,11 +28,6 @@ ], "codeExt": "\\.(js|mjs|cjs|ts|jsx|tsx|py|sh|yml|yaml|json|html|css)$", "diffPatterns": [ - "\\bchild_process\\b", - "\\beval\\(", - "new Function\\(", - "\\bexec(Sync)?\\(['\"]", - "\\bos\\.system\\(|\\bsubprocess\\.(run|call|Popen|check_output)", "process\\.env\\.[A-Za-z_]*(TOKEN|KEY|SECRET)", "os\\.environ(\\.get)?[\\[(][^\\n]{0,60}(TOKEN|KEY|SECRET)", "\\.dsh(?![-\\w])|DSH_HOME", @@ -42,7 +37,12 @@ ], "diffPatternsNotInTests": [ "https?://(?!(localhost|127\\.0\\.0\\.1|example\\.(com|org)|github\\.com/(ThinkFlowLab|Birfy)|raw\\.githubusercontent\\.com/(ThinkFlowLab|Birfy)|registry\\.npmjs\\.org))", - "untrusted-(message|file)|\\bfence|sanitiz|displayName|display name" + "untrusted-(message|file)|\\bfence|sanitiz|displayName|display name", + "\\bchild_process\\b", + "\\beval\\(", + "new Function\\(", + "\\bexec(Sync)?\\(['\"]", + "\\bos\\.system\\(|\\bsubprocess\\.(run|call|Popen|check_output)" ], "testPaths": ["tests/**", "**/test/**", "**/tests/**", "**/*.test.{js,mjs,cjs,ts,jsx,tsx}", "**/test_*.py", "**/*_test.py"], "topics": [] From dbc8209473e2fe9798fed8498b317866cf1428a7 Mon Sep 17 00:00:00 2001 From: Danyang Chen Date: Fri, 27 Nov 2026 14:04:17 +0800 Subject: [PATCH 2/2] ci: test the exec-family rule split between product code and tests (#3393) One test for the split: a spawned or evaluated line in a test file no longer raises the tier, the same line in product code still does, and `.only(` still counts inside a test. Related #3393 --- .github/scripts/risk-gate.test.mjs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/scripts/risk-gate.test.mjs b/.github/scripts/risk-gate.test.mjs index d91787a65..6d7dacf03 100644 --- a/.github/scripts/risk-gate.test.mjs +++ b/.github/scripts/risk-gate.test.mjs @@ -76,6 +76,18 @@ test('judge: content hits in added lines of code raise to T3', () => { } }) +test('judge: exec-family hits in a test file stay out of the tier, in product code they still count', () => { + // These two patterns used to hit fixtures: #3382 was called T3 for `new Function(` inside + // runtime/flybot/plugins/social/test/. A test that evaluates or spawns is ordinary test + // machinery, so those patterns are read on product code only. `.only(` and the lint + // suppressions stay in `diffPatterns`, because in a test file they still mean something. + const spawned = ["+import { exec } from 'node:child_process'"] + assert.notEqual(gate.judge([file('tests/harness.mjs', spawned)]).tier, 'T3', 'test helper') + assert.notEqual(gate.judge([file('runtime/flybot/plugins/social/test/poll-visibility.test.js', ['+new Function(source)'])]).tier, 'T3', 'test fixture') + assert.equal(gate.judge([file('runtime/flybot/plugins/social/src/a.js', spawned)]).tier, 'T3', 'product code still counts') + assert.equal(gate.judge([file('tests/test_a.py', ['+test.only("x")'])]).tier, 'T3', '.only still counts in a test') +}) + test('#679: a topic counts on the registration line, not on a line that names the tool', () => { // The rule survives the port even though no tool in this tree registers a topic yet (`topics` is // empty): a plain substring match made any mention of a tool a T3 PR, so the narrow form is kept