fix(squad): require action-plan table separator and equal columns

Reject 待续 status-cell exemptions unless the same contiguous table has a header immediately followed by a valid separator and the data row width matches the header.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
weichen
2026-09-13 16:10:24 +00:00
co-authored by Cursor
parent dee18d7fc0
commit 75345431e4
2 changed files with 28 additions and 4 deletions
+17 -4
View File
@@ -254,6 +254,7 @@ var (
// isActionPlanStatusCell 仅豁免行动计划/后续动作表中「阶段/状态/进度」列的独立单元格「待续」。
// 命中列必须与表头状态列索引一致;动作/负责/触发按表头取值。不得凭同行任意列或邻近词放宽。
// 只接受同一连续表格:表头后须紧跟合法 separator,且数据行列数与表头相等。
func isActionPlanStatusCell(content string, idx int, phrase string) bool {
if phrase != "待续" || idx < 0 || idx >= len(content) {
return false
@@ -271,6 +272,9 @@ func isActionPlanStatusCell(content string, idx int, phrase string) bool {
return false
}
header := findPrecedingTableHeader(content, lineStart)
if len(header) == 0 || len(cells) != len(header) {
return false
}
cols, ok := parseActionPlanColumns(header)
if !ok {
return false
@@ -372,7 +376,7 @@ func hasSubstantialActionText(s string) bool {
}
func findPrecedingTableHeader(content string, lineStart int) []string {
var header []string
var above []string
prevEnd := lineStart - 1
for prevEnd >= 0 {
prevStart := 0
@@ -389,11 +393,20 @@ func findPrecedingTableHeader(content string, lineStart int) []string {
if cells == nil {
break
}
if !isMarkdownTableSeparator(cells) {
header = cells
}
above = append(above, line)
prevEnd = prevStart - 1
}
if len(above) < 2 {
return nil
}
header := markdownTableCells(above[len(above)-1])
sep := markdownTableCells(above[len(above)-2])
if len(header) == 0 || isMarkdownTableSeparator(header) {
return nil
}
if !isMarkdownTableSeparator(sep) || len(sep) != len(header) {
return nil
}
return header
}
+11
View File
@@ -416,6 +416,17 @@ func TestQualityGate_PendingPhrase_HostileContextsStillFail(t *testing.T) {
| 阶段 | 行动项 | 负责方 | 触发条件 |
|---|---|---|---|
| 立即 | 合规专员基于用户补充材料评估符合性并出具初步意见。 | 合规专员 | 待续 |
`},
{"no_header_separator", `### 下一步行动建议
| 阶段 | 行动项 | 负责方 | 触发条件 |
| **待续** | 合规专员基于用户补充材料评估符合性并出具初步意见。 | 合规专员 | D-01确认后 |
`},
{"header_4_data_5", `### 下一步行动建议
| 阶段 | 行动项 | 负责方 | 触发条件 |
|---|---|---|---|
| **待续** | 合规专员基于用户补充材料评估符合性并出具初步意见。 | 合规专员 | D-01确认后 | 额外列 |
`},
}