feat(B): 验收 DSL 编译器 + 骨架熵仪器(IR-0004 AC-8/AC-9 rev6,卡 .github#329/#330) - #100
Conversation
bd7a8e2 to
7794a20
Compare
|
Warning Review limit reachedNext included review available in 2 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughChanges该 PR 新增验收 DSL 编译与 hash 溯源校验工具、可复用 PR 门禁工作流,以及骨架方差分析工具。新增文档说明接口、职责边界、输出格式和自测命令。 DSL 编译与生成物校验
PR 工作流门禁
骨架方差分析与输出
Suggested labels: ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
| - name: Checkout 检测器(CI-Workflows 同源副本,只读) | ||
| if: github.event_name == 'pull_request' && inputs.detector-ref != '' | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| repository: Cloudbird-Software/CI-Workflows | ||
| ref: ${{ inputs.detector-ref }} | ||
| path: detector | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Python 3.11(stdlib only——零 pip 依赖,无网络需求) |
PR Summary by QodoAdd spec DSL compiler/verify gate and skeleton divergence instrument (IR-0004 AC-8/9)
AI Description
Diagram
High-Level Assessment
Files changed (20)
|
Code Review by Qodo
1. Indented AC lists rejected
|
| for d in $(printf '%s\n' "${CHANGED[@]}" | xargs -n1 dirname | sort -u); do | ||
| SPEC="$d/spec.md" | ||
| if [ ! -f "$SPEC" ]; then | ||
| echo "::error::$SPEC 不存在($d 有变更但缺 spec.md)" | ||
| FAIL=1; continue |
There was a problem hiding this comment.
1. Nested changes use wrong spec 🐞 Bug ≡ Correctness
The workflow maps each changed file to its immediate parent and appends /spec.md, so a change to specs/<IR>/suite/generated/test_*.py looks for specs/<IR>/suite/generated/spec.md instead of specs/<IR>/spec.md. This causes generated-test changes to be rejected as “missing spec” before compilation and the advertised provenance/hash verification can run.
Agent Prompt
## Issue description
Changed files nested below a spec root are treated as though their immediate parent were the spec directory (by doing `dirname` + `/spec.md`), which fails for nested generated files and causes false missing-spec failures that prevent compilation and generated artifact provenance/hash verification.
## Issue Context
A valid generated output is located below `specs/<IR>/suite/generated/`, while its source of truth is `specs/<IR>/spec.md`. For each changed path, the workflow should locate the nearest owning ancestor containing `spec.md` under the `specs` directory (rather than blindly appending `spec.md` to `dirname`), and handle any grouping/metadata concerns separately from determining the owning spec directory.
## Fix Focus Areas
- .github/workflows/spec-dsl-gate.yml[83-110]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| with open(out / "fanout-products.jsonl", "w", encoding="utf-8", newline="\n") as f: | ||
| for rec in fanout_records(report, card_id, spec_hash, base_sha): | ||
| f.write(json.dumps(rec, ensure_ascii=False) + "\n") |
There was a problem hiding this comment.
2. Append-only records are truncated 🐞 Bug ☼ Reliability
write_outputs() opens fanout-products.jsonl in "w" mode, deleting all existing fuel records whenever the output directory is reused. This contradicts the stated append-only contract and loses prior divergence and assumption records.
Agent Prompt
## Issue description
Every run truncates the append-only fanout product file and destroys records produced by earlier runs.
## Issue Context
Write new JSONL records using append-safe behavior consistent with the contract, while retaining deterministic overwrite behavior for the standalone report if desired.
## Fix Focus Areas
- pipeline/entropy/divergence.py[255-262]
- pipeline/INSTRUMENTS-B.md[46-48]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| if raw.startswith("- "): # 新列表项(首字段随行) | ||
| cur = {} | ||
| acs.append(cur) | ||
| _fill(cur, raw[2:].strip(), source) | ||
| elif raw.startswith(" ") and cur is not None and ":" in raw: | ||
| _fill(cur, raw.strip(), source) | ||
| else: # 下一个零缩进键 → 节终止 | ||
| break |
There was a problem hiding this comment.
3. Indented ac lists rejected 🐞 Bug ≡ Correctness
extract_acceptance_criteria() treats a new acceptance-criteria item as valid only when - starts in column zero, but the repository’s canonical YAML spec format nests list entries under acceptanceCriteria: with two-space indentation. This causes acs to be parsed as empty and valid specs to be rejected, making the new compiler/PR gate fail on existing specs that the YAML-based validator accepts.
Agent Prompt
## Issue description
The DSL parser rejects valid `acceptanceCriteria` lists because `extract_acceptance_criteria()` only recognizes list items when `- ` begins at column zero, while repository specs (including fixtures/templates) use standard YAML nesting with two-space-indented list entries under `acceptanceCriteria:`.
## Issue Context
Repository specs place acceptance-criteria items beneath the YAML key and indent them (e.g., ` - id: ...`). The new parser currently branches only on unindented list markers, which results in `acs` being empty and triggers the parser’s empty-list failure, causing the new compiler/PR gate to reject specs that the canonical YAML-based spec validator (using `yaml.safe_load`) accepts.
## Fix Focus Areas
- pipeline/dsl/compile.py[83-116]
- pipeline/adversary/fixtures/intent-backstop/clean-spec.md[6-10]
- scripts/spec-check.py[94-126]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| as_union = sorted({it for m in as_maps for it in m.values()}) | ||
|
|
||
| convergence = round(100.0 * len(inter_keys) / len(union_keys), 2) if union_keys else 0.0 | ||
| mean_sim = round(sum(p["similarity"] for p in pairs) / len(pairs), 4) |
There was a problem hiding this comment.
4. Single skeleton crashes cli 🐞 Bug ☼ Reliability
A directory containing exactly one valid skeleton passes the non-empty directory validation but produces no pair combinations, causing the mean pair similarity (mean_sim/mean_pair_similarity) calculation to divide by zero. Because the CLI only catches EntropyError, this otherwise valid input triggers an uncaught ZeroDivisionError traceback instead of a controlled report or input error consistent with documented exit behavior.
Agent Prompt
## Issue description
A directory with exactly one valid skeleton currently passes input validation but generates zero pairwise combinations, leading the mean pair similarity calculation to divide by zero and crash with an uncaught `ZeroDivisionError`.
## Issue Context
The tool’s directory validation only rejects directories with zero `.md` files, but pairwise metrics inherently require at least two skeleton inputs. The CLI currently catches only `EntropyError`, so the division-by-zero escapes and violates the expected/documented controlled CLI exit behavior; the fix should either reject fewer than two skeletons via `EntropyError` or define an explicit, intentional behavior for the no-pairs case (and ensure it is covered by a CLI test).
## Fix Focus Areas
- pipeline/entropy/divergence.py[156-173]
- pipeline/entropy/divergence.py[213-214]
- pipeline/entropy/divergence.py[282-287]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
| body.append(f"def {fname}():") | ||
| body.append(f' """{ac["id"]}') | ||
| body.append("") | ||
| body.append(f" given: {_esc_doc(ac['given'])}") | ||
| body.append(f" when: {_esc_doc(ac['when'])}") | ||
| body.append(f" then: {_esc_doc(ac['then'])}") |
There was a problem hiding this comment.
5. Ac id breaks generated python 🐞 Bug ☼ Reliability
The raw AC ID is inserted into a triple-quoted docstring without escaping, although the other AC text is escaped. A valid YAML string such as id: 'AC-1"""' passes the DSL field checks but generates syntactically invalid Python; verify.py re-renders the same invalid text and reports it green.
Agent Prompt
## Issue description
Raw AC IDs are emitted inside Python triple-quoted docstrings and can terminate the literal, producing invalid generated test files.
## Issue Context
The existing spec validator only requires an ID to be a non-empty string, and the compiler already has an escaping helper for the other docstring fields.
## Fix Focus Areas
- pipeline/dsl/compile.py[119-125]
- pipeline/dsl/compile.py[145-166]
- scripts/spec-check.py[111-126]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
变更
运行时证据
子代理自测 28 用例全绿(含对 IR-0004 真实 spec 的编译→verify 全链对拍、21 测试函数 pytest 实收、手改 hash 头不动也红的负向);集成后本地复跑 py_compile+YAML 通过。
依据
IR-0004 rev6(PR .github#359);ADR-0085 决策 7(门禁由 spec 自然携带、系统强制)。
Summary by CodeRabbit
新功能
文档
Cards: Cloudbird-Software/.github#329 Cloudbird-Software/.github#330