auto(14b5ea1b9bd9): session end @ 2026-07-29T10:06:19 (+3f)
This commit is contained in:
1 parent
42e3372096
commit
d30ba199d3
3 files changed
+9
-230
No files matched your search
@@ -5,7 +5,7 @@
|
||||
# [1] tsc --noEmit → 0 错误 (硬阻断)
|
||||
# [2] vitest run tests/unit → 全绿 (硬阻断)
|
||||
# [3] doc:check → 0 drift (硬阻断)
|
||||
# [4] validate-baseline → JNPF7 5 层验证闭环 L1-L5 全绿 (硬阻断, P1-16)
|
||||
# [4] validate-baseline → JNPF 4 层验证闭环 L1-L4 全绿 (硬阻断, P1-16)
|
||||
# [5] backend smoke → 有 live 后端才跑 (本地 advisory, CI 强制)
|
||||
#
|
||||
# 无仪式: 不 grep 魔法串 / 不查注释出处 / 不看行数下限.
|
||||
@@ -38,9 +38,9 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔒 dacli 质量门 [4/5] validate-baseline (JNPF7 5 层验证闭环, P1-16) ..."
|
||||
echo "🔒 dacli 质量门 [4/5] validate-baseline (JNPF 4 层验证闭环, P1-16) ..."
|
||||
if sh scripts/validate-baseline.sh >/tmp/dacli-validate-baseline.log 2>&1; then
|
||||
echo " ✓ validate-baseline: L1-L5 全绿 (23/29 handled + 6 pass-through)"
|
||||
echo " ✓ validate-baseline: L1-L4 全绿 (23/29 handled + 6 pass-through)"
|
||||
else
|
||||
echo " ✗ validate-baseline: 有失败 — 阻断 commit"
|
||||
echo " 详见 /tmp/dacli-validate-baseline.log 或跑 bash scripts/validate-baseline.sh"
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#!/bin/bash
|
||||
# dacli/scripts/validate-baseline.sh — CI gate for JNPF7 antipattern baseline
|
||||
# dacli/scripts/validate-baseline.sh — CI gate for JNPF antipattern baseline
|
||||
#
|
||||
# Runs all 5 validation layers + vitest regression suite.
|
||||
# Runs all 4 validation layers + vitest regression suite.
|
||||
# Exit 0 = all pass; Exit 1 = one or more failures
|
||||
#
|
||||
# 注: 原 L5 (Static Prompt A/B Comparison) 已移除 (2026-07-29).
|
||||
# jnpf7 是临时对照目录, 该层不再需要. tools/prompt-ab-static.ts 已删除.
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/validate-baseline.sh
|
||||
# bash scripts/validate-baseline.sh --skip-llm # skip tests that need base_ai
|
||||
@@ -16,7 +19,7 @@ SKIP_LLM=false
|
||||
[ "$1" = "--skip-llm" ] && SKIP_LLM=true
|
||||
|
||||
echo "=========================================="
|
||||
echo " dacli 5-Layer Validation Baseline"
|
||||
echo " dacli 4-Layer Validation Baseline"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
@@ -66,11 +69,6 @@ echo "── L4: Historical BS Case Replay ──"
|
||||
npx tsx tools/replay-history.ts
|
||||
echo ""
|
||||
|
||||
# Layer 5 — Static A/B
|
||||
echo "── L5: Static Prompt A/B Comparison ──"
|
||||
npx tsx tools/prompt-ab-static.ts
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo " ✓ All baseline validations completed"
|
||||
echo "=========================================="
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
/**
|
||||
* L5 — Static Prompt A/B Comparison (no LLM calls)
|
||||
*
|
||||
* Compares JNPF7's GEN_MODEL_QUETION (legacy v2 prompt) with dacli's
|
||||
* BUILD_FORM_PROMPT (v0.22+ SSW path) on structural/capability dimensions.
|
||||
*
|
||||
* This is a STATIC comparison — we don't call any LLM. We extract prompt
|
||||
* features (length, constraints, examples) and compare.
|
||||
*
|
||||
* For full A/B with LLM calls, see docs/dacli-prompt-ab-2026-07-27.md
|
||||
* (run separately with `dacli form create --ai <desc>` against both prompts).
|
||||
*
|
||||
* Usage:
|
||||
* npx tsx tools/prompt-ab-static.ts
|
||||
* npx tsx tools/prompt-ab-static.ts --md > /tmp/ab.md
|
||||
*/
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
const JNPF_FILE = '/home/ubuntu/ccWorkDir/jnpf/jnpf7/jnpf-java-ai-core/jnpf-common-ai-core/src/main/java/jnpf/constants/AiConstants.java'
|
||||
const DACLI_FILE = '/home/ubuntu/ccWorkDir/boot/ssw-common/ssw-common-biz/src/main/java/ssw/common/service/impl/AIRepairServiceImpl.java'
|
||||
|
||||
function extractBetweenQuotes(content: string, marker: string): string {
|
||||
const idx = content.indexOf(marker)
|
||||
if (idx === -1) return ''
|
||||
// Skip to first quote
|
||||
let i = content.indexOf('"', idx)
|
||||
if (i === -1) return ''
|
||||
let result = ''
|
||||
i++
|
||||
while (i < content.length) {
|
||||
const ch = content[i]
|
||||
if (ch === '"' && content[i - 1] !== '\\') break
|
||||
result += ch
|
||||
i++
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function extractJnpfPrompt(content: string, name: string): string {
|
||||
// JNPF7 uses `public static final String NAME = "..." + "..." + ... ;` (concatenated multi-line)
|
||||
const marker = `String ${name} =`
|
||||
const idx = content.indexOf(marker)
|
||||
if (idx === -1) return ''
|
||||
// Scan forward: collect all string literals until final ;
|
||||
let i = idx + marker.length
|
||||
let result = ''
|
||||
while (i < content.length) {
|
||||
// Skip whitespace
|
||||
while (i < content.length && /\s/.test(content[i])) i++
|
||||
if (i >= content.length) break
|
||||
if (content[i] === ';') break
|
||||
if (content[i] !== '"') {
|
||||
// skip non-string tokens like GEN_MODEL_COMPNENT
|
||||
while (i < content.length && content[i] !== '"' && content[i] !== ';') i++
|
||||
continue
|
||||
}
|
||||
// We're at a string literal start
|
||||
i++ // skip opening "
|
||||
while (i < content.length) {
|
||||
const ch = content[i]
|
||||
if (ch === '"' && content[i - 1] !== '\\') break
|
||||
result += ch
|
||||
i++
|
||||
if (result.length > 100000) break
|
||||
}
|
||||
i++ // skip closing "
|
||||
if (result.length > 100000) break
|
||||
}
|
||||
return result.replace(/\\n/g, '\n').replace(/\\t/g, '\t').replace(/\\"/g, '"')
|
||||
}
|
||||
|
||||
// JNPF7's prompt is concatenated with "+" in Java; dacli's uses "\n" + "\n"
|
||||
// For dacli, we need to extract the BUILD_FORM_PROMPT region
|
||||
function extractDacliPrompt(content: string): string {
|
||||
const start = content.indexOf('private static final String BUILD_FORM_PROMPT =')
|
||||
if (start === -1) return ''
|
||||
// Find matching ";" at end of declaration
|
||||
let i = start
|
||||
let depth = 0
|
||||
let inString = false
|
||||
let result = ''
|
||||
while (i < content.length) {
|
||||
const ch = content[i]
|
||||
if (ch === '"' && content[i - 1] !== '\\') inString = !inString
|
||||
if (!inString && ch === ';' && depth === 0) {
|
||||
// Check if this is the prompt's terminator (vs inner ;)
|
||||
const rest = content.slice(i + 1, i + 100).trim()
|
||||
if (rest.startsWith('private') || rest.startsWith('@Override')) break
|
||||
}
|
||||
result += ch
|
||||
i++
|
||||
if (result.length > 100000) break
|
||||
}
|
||||
// Unescape \n
|
||||
return result.replace(/\\n/g, '\n').replace(/\\t/g, '\t').replace(/\\"/g, '"')
|
||||
}
|
||||
|
||||
interface PromptFeatures {
|
||||
name: string
|
||||
length: number
|
||||
hasForbiddenRules: boolean
|
||||
forbiddenRuleCount: number
|
||||
hasWhitelist: boolean
|
||||
whitelistSize: number
|
||||
hasFprefixRule: boolean
|
||||
hasSnakeCaseRule: boolean
|
||||
hasRelationFormRule: boolean
|
||||
relationFormFieldCount: number
|
||||
hasOutputExample: boolean
|
||||
hasRecencyBias: boolean
|
||||
hasMinFieldSet: boolean
|
||||
hasKeywordForbiddenList: boolean
|
||||
isMainExplicit: boolean
|
||||
hasFieldDbType: boolean
|
||||
}
|
||||
|
||||
function analyze(name: string, prompt: string, hasRecencyBias: boolean): PromptFeatures {
|
||||
// Count forbidden rules (look for "禁用" mentions)
|
||||
const forbiddenMatches = prompt.match(/禁用\s*\S+/g) ?? []
|
||||
// Whitelist: look for "白名单" or component enumeration
|
||||
const whitelistMatch = prompt.match(/input[\s\S]{0,300}datePicker[\s\S]{0,300}timePicker/)
|
||||
// relationForm 7 fields: modelId, propsValue, relationField, showField, hasPage, queryType, columnOptions
|
||||
const relFields = ['modelId', 'propsValue', 'relationField', 'showField', 'hasPage', 'queryType', 'columnOptions']
|
||||
const relFieldCount = relFields.filter(f => prompt.includes(f)).length
|
||||
|
||||
return {
|
||||
name,
|
||||
length: prompt.length,
|
||||
hasForbiddenRules: forbiddenMatches.length > 0,
|
||||
forbiddenRuleCount: forbiddenMatches.length,
|
||||
hasWhitelist: whitelistMatch !== null || /白名单/.test(prompt),
|
||||
whitelistSize: (prompt.match(/['"]?(\w+)['"]?\s*[,,]\s*/g) ?? []).length, // rough
|
||||
hasFprefixRule: /f_\s*开头|f_xxx_yyy/.test(prompt),
|
||||
hasSnakeCaseRule: /snake_case/.test(prompt),
|
||||
hasRelationFormRule: /relationForm/.test(prompt),
|
||||
relationFormFieldCount: relFieldCount,
|
||||
hasOutputExample: /示例|example/.test(prompt),
|
||||
hasRecencyBias,
|
||||
hasMinFieldSet: /最小字段|必含/.test(prompt),
|
||||
hasKeywordForbiddenList: /SQL\s*关键字|禁词|reserved|关键字/.test(prompt),
|
||||
isMainExplicit: /isMain/.test(prompt),
|
||||
hasFieldDbType: /fieldDbType/.test(prompt),
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const args = process.argv.slice(2)
|
||||
const mdMode = args.includes('--md')
|
||||
|
||||
const jnpfContent = readFileSync(JNPF_FILE, 'utf8')
|
||||
const dacliContent = readFileSync(DACLI_FILE, 'utf8')
|
||||
|
||||
// JNPF7 GEN_MODEL_QUETION
|
||||
const jnpfPrompt = extractJnpfPrompt(jnpfContent, 'GEN_MODEL_QUETION')
|
||||
|
||||
const dacliPrompt = extractDacliPrompt(dacliContent)
|
||||
|
||||
// Check recency bias in dacli (user prompt section)
|
||||
const hasRecencyBias = /末尾重申/.test(dacliContent)
|
||||
|
||||
const jnpfFeatures = analyze('JNPF7 GEN_MODEL_QUETION', jnpfPrompt, false)
|
||||
const dacliFeatures = analyze('dacli BUILD_FORM_PROMPT', dacliPrompt, hasRecencyBias)
|
||||
|
||||
if (mdMode) {
|
||||
console.log('# Prompt A/B Static Comparison\n')
|
||||
console.log('| Feature | JNPF7 GEN_MODEL_QUETION | dacli BUILD_FORM_PROMPT | Winner |')
|
||||
console.log('|---------|--------------------------|------------------------|--------|')
|
||||
const rows: [string, any, any, string][] = [
|
||||
['Length (chars)', jnpfFeatures.length, dacliFeatures.length, dacliFeatures.length > jnpfFeatures.length ? 'dacli' : 'JNPF7'],
|
||||
['Forbidden rules count', jnpfFeatures.forbiddenRuleCount, dacliFeatures.forbiddenRuleCount, dacliFeatures.forbiddenRuleCount > jnpfFeatures.forbiddenRuleCount ? 'dacli' : 'JNPF7'],
|
||||
['Whitelist declared', jnpfFeatures.hasWhitelist ? '✓' : '✗', dacliFeatures.hasWhitelist ? '✓' : '✗', '—'],
|
||||
['f_ prefix rule', jnpfFeatures.hasFprefixRule ? '✓' : '✗', dacliFeatures.hasFprefixRule ? '✓' : '✗', 'dacli (dacli-specific)'],
|
||||
['snake_case rule', jnpfFeatures.hasSnakeCaseRule ? '✓' : '✗', dacliFeatures.hasSnakeCaseRule ? '✓' : '✗', 'dacli (dacli-specific)'],
|
||||
['relationForm rule', jnpfFeatures.hasRelationFormRule ? '✓' : '✗', dacliFeatures.hasRelationFormRule ? '✓' : '✗', '—'],
|
||||
['relationForm 7-fields specified', `${jnpfFeatures.relationFormFieldCount}/7`, `${dacliFeatures.relationFormFieldCount}/7`, dacliFeatures.relationFormFieldCount === 7 ? 'dacli' : '—'],
|
||||
['Output example', jnpfFeatures.hasOutputExample ? '✓' : '✗', dacliFeatures.hasOutputExample ? '✓' : '✗', '—'],
|
||||
['Recency bias (user prompt end)', '✗', dacliFeatures.hasRecencyBias ? '✓' : '✗', 'dacli (v0.23+ tdd4 fix)'],
|
||||
['Min field set', jnpfFeatures.hasMinFieldSet ? '✓' : '✗', dacliFeatures.hasMinFieldSet ? '✓' : '✗', '—'],
|
||||
['Keyword forbidden list', jnpfFeatures.hasKeywordForbiddenList ? '✓' : '✗', dacliFeatures.hasKeywordForbiddenList ? '✓' : '✗', '—'],
|
||||
['isMain explicit', jnpfFeatures.isMainExplicit ? '✓' : '✗', dacliFeatures.isMainExplicit ? '✓' : '✗', '—'],
|
||||
['fieldDbType specified', jnpfFeatures.hasFieldDbType ? '✓' : '✗', dacliFeatures.hasFieldDbType ? '✓' : '✗', '—'],
|
||||
]
|
||||
for (const [feature, jnpf, dacli, winner] of rows) {
|
||||
console.log(`| ${feature} | ${jnpf} | ${dacli} | ${winner} |`)
|
||||
}
|
||||
console.log('')
|
||||
console.log('## Conclusion')
|
||||
console.log('')
|
||||
console.log('**dacli优势**: 7 forbidden rules + recency bias + relationForm 7-fields 全覆盖 + 字段命名规范')
|
||||
console.log('**JNPF7优势**: 无 — 他们的 GEN_MODEL_QUETION 偏向轻量级示例驱动')
|
||||
console.log('**注**: 这只是静态对比。完整 A/B 需要在同 base_ai 配置下用相同 10 case 测试集实际跑 LLM,对比输出。')
|
||||
return
|
||||
}
|
||||
|
||||
console.log('\n=== Static Prompt A/B Comparison ===\n')
|
||||
console.log('JNPF7 GEN_MODEL_QUETION:')
|
||||
console.log(` Length: ${jnpfFeatures.length} chars`)
|
||||
console.log(` Forbidden rules: ${jnpfFeatures.forbiddenRuleCount}`)
|
||||
console.log(` Whitelist: ${jnpfFeatures.hasWhitelist ? '✓' : '✗'}`)
|
||||
console.log(` f_ prefix rule: ${jnpfFeatures.hasFprefixRule ? '✓' : '✗'}`)
|
||||
console.log(` snake_case rule: ${jnpfFeatures.hasSnakeCaseRule ? '✓' : '✗'}`)
|
||||
console.log(` relationForm rule: ${jnpfFeatures.hasRelationFormRule ? '✓' : '✗'}`)
|
||||
console.log(` relationForm fields: ${jnpfFeatures.relationFormFieldCount}/7`)
|
||||
console.log(` Recency bias: ${jnpfFeatures.hasRecencyBias ? '✓' : '✗'}`)
|
||||
console.log()
|
||||
console.log('dacli BUILD_FORM_PROMPT:')
|
||||
console.log(` Length: ${dacliFeatures.length} chars`)
|
||||
console.log(` Forbidden rules: ${dacliFeatures.forbiddenRuleCount}`)
|
||||
console.log(` Whitelist: ${dacliFeatures.hasWhitelist ? '✓' : '✗'}`)
|
||||
console.log(` f_ prefix rule: ${dacliFeatures.hasFprefixRule ? '✓' : '✗'}`)
|
||||
console.log(` snake_case rule: ${dacliFeatures.hasSnakeCaseRule ? '✓' : '✗'}`)
|
||||
console.log(` relationForm rule: ${dacliFeatures.hasRelationFormRule ? '✓' : '✗'}`)
|
||||
console.log(` relationForm fields: ${dacliFeatures.relationFormFieldCount}/7`)
|
||||
console.log(` Recency bias: ${dacliFeatures.hasRecencyBias ? '✓' : '✗'}`)
|
||||
console.log()
|
||||
console.log('Use --md flag for markdown report')
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in new issue
Block a user