@@ -103,30 +103,88 @@ function findActiveTaskRoot (state) {
103103 }
104104}
105105
106+ /** Minimum UTF-8 bytes for a substantive PR-1 review body (blocks two-line green). */
107+ const PR1_MIN_BODY_BYTES = 1200
108+
106109/**
107- * F-04: PR-1 pass evidence must be strong (zero-blocker / explicit pass row).
108- * Rejects loose "某某通过" alone.
110+ * F-04 / SkillsDeployMode PR-1 strengthen:
111+ * When 02-技术方案 exists, require an independent 03 review file with
112+ * pass signal AND substance (mapping/contract/CodeTruth/blocker/root-cause).
113+ * Rejects: open-blocker-only, table-only PR-1 ✅, sessions-only with 02 present.
109114 */
110- function pr1EvidenceOk ( taskRoot ) {
111- if ( ! taskRoot || ! fs . existsSync ( taskRoot ) ) return false
115+ function findPr1ReviewFileName ( taskRoot ) {
116+ if ( ! taskRoot || ! fs . existsSync ( taskRoot ) ) return null
112117 try {
113118 const files = fs . readdirSync ( taskRoot )
114- const review = files . find ( f =>
119+ return files . find ( f =>
115120 / ^ 0 3 - .* 方 案 复 审 / i. test ( f ) ||
121+ / ^ 0 3 - .* 方 案 自 审 / i. test ( f ) ||
116122 / ^ 0 4 - .* 方 案 复 审 / i. test ( f ) ||
117123 / 方 案 复 审 / i. test ( f )
118- )
124+ ) || null
125+ } catch {
126+ return null
127+ }
128+ }
129+
130+ function controlPlaneHint ( taskRoot ) {
131+ try {
132+ const tech = path . join ( taskRoot , '02-技术方案.md' )
133+ if ( ! fs . existsSync ( tech ) ) return false
134+ const text = fs . readFileSync ( tech , 'utf8' )
135+ return / h o o k | l i f e c y c l e | s k i l l s D e p l o y | a p p l y G l o b a l H o s t | c o n t r o l .? p l a n e | 控 制 面 | g l o b a l - h o s t - c o n f i g | p r 1 E v i d e n c e O k / i. test ( text )
136+ } catch {
137+ return false
138+ }
139+ }
140+
141+ function countPr1Substance ( body ) {
142+ let substance = 0
143+ if ( / B l o c k e r S n a p s h o t | 阻 断 项 | b l o c k e r I d / i. test ( body ) ) substance += 1
144+ if ( / 验 收 映 射 | 需 求 [ ^ \n ] { 0 , 12 } 映 射 | 产 品 事 实 源 | § 0 \. 5 / i. test ( body ) ) substance += 1
145+ if ( / 契 约 矩 阵 | C o n t r a c t M a t r i x | C u r r e n t \s * → \s * T a r g e t | r u n t i m e O w n e r s / i. test ( body ) ) substance += 1
146+ if ( / C o d e T r u t h | c u r r e n t B e h a v i o r | n e g a t i v e P r o b e | r e p o P a t h / i. test ( body ) ) substance += 1
147+ if ( / 根 因 | R o o t \s * c a u s e | 假 绿 | p r 1 E v i d e n c e O k / i. test ( body ) ) substance += 1
148+ return substance
149+ }
150+
151+ function pr1ReviewBodyOk ( body , taskRoot ) {
152+ const text = String ( body || '' )
153+ if ( ! / P R - 1 / i. test ( text ) ) return false
154+ if ( / P R - 1 [ ^ \n ] { 0 , 40 } (?: 不 通 过 | 阻 断 | f a i l | ❌ ) / i. test ( text ) ) return false
155+ if ( Buffer . byteLength ( text , 'utf8' ) < PR1_MIN_BODY_BYTES ) return false
156+
157+ const hasPass =
158+ / o p e n \s * b l o c k e r \s * = \s * 0 | z e r o \s * b l o c k e r | b l o c k e r s ? \s * = \s * 0 / i. test ( text ) ||
159+ / P R - 1 [ ^ \n ] { 0 , 40 } (?: ✅ \s * 通 过 | 通 过 \s * ✅ | = \s * p a s s | : \s * p a s s ) / i. test ( text ) ||
160+ / 阶 段 一 [ ^ \n ] { 0 , 30 } P R - 1 [ ^ \n ] { 0 , 30 } ✅ / i. test ( text )
161+ // Bare "| PR-1 | ✅ |" table rows alone are NOT a pass signal (thin-green).
162+ if ( ! hasPass ) return false
163+
164+ const substance = countPr1Substance ( text )
165+ const minSubstance = controlPlaneHint ( taskRoot ) ? 2 : 2
166+ return substance >= minSubstance
167+ }
168+
169+ function pr1EvidenceOk ( taskRoot ) {
170+ if ( ! taskRoot || ! fs . existsSync ( taskRoot ) ) return false
171+ try {
172+ const hasTech = hasTechDesign ( taskRoot )
173+ const review = findPr1ReviewFileName ( taskRoot )
174+
175+ // With a tech design, sessions-only is never enough — require independent 03 review.
176+ if ( hasTech ) {
177+ if ( ! review ) return false
178+ const body = fs . readFileSync ( path . join ( taskRoot , review ) , 'utf8' )
179+ return pr1ReviewBodyOk ( body , taskRoot )
180+ }
181+
119182 if ( review ) {
120183 const body = fs . readFileSync ( path . join ( taskRoot , review ) , 'utf8' )
121- if ( ! / P R - 1 / i. test ( body ) ) return false
122- // Strong pass signals only
123- if ( / o p e n \s * b l o c k e r \s * = \s * 0 | z e r o \s * b l o c k e r | b l o c k e r s ? \s * = \s * 0 / i. test ( body ) ) return true
124- if ( / P R - 1 [ ^ \n ] { 0 , 40 } (?: ✅ \s * 通 过 | 通 过 \s * ✅ | = \s * p a s s | : \s * p a s s ) / i. test ( body ) ) return true
125- if ( / 阶 段 一 [ ^ \n ] { 0 , 30 } P R - 1 [ ^ \n ] { 0 , 30 } ✅ / i. test ( body ) ) return true
126- if ( / P R - 1 \s * [ | : : ] \s * ✅ / i. test ( body ) ) return true
127- // Explicit fail
128- if ( / P R - 1 [ ^ \n ] { 0 , 40 } (?: 不 通 过 | 阻 断 | f a i l | ❌ ) / i. test ( body ) ) return false
184+ return pr1ReviewBodyOk ( body , taskRoot )
129185 }
186+
187+ // Legacy: no 02 present — sessions row may still count for non-CP2 callers.
130188 const sessions = path . join ( taskRoot , '.memory' , 'sessions.md' )
131189 if ( fs . existsSync ( sessions ) ) {
132190 const s = fs . readFileSync ( sessions , 'utf8' )
@@ -320,6 +378,11 @@ module.exports = {
320378 extractLastAssistantMessage,
321379 askingCp2Confirm,
322380 pr1EvidenceOk,
381+ pr1ReviewBodyOk,
382+ countPr1Substance,
383+ findPr1ReviewFileName,
384+ controlPlaneHint,
385+ PR1_MIN_BODY_BYTES ,
323386 completionClaimed,
324387 hasEntryCheck,
325388 hasCompletionCheck,
0 commit comments