Skip to content

feat(standards): Phase 1 lossless canonical standard layer + alignment audit - #14

Merged
xianyu9n merged 4 commits into
masterfrom
feat/phase1-canonical-standard
Aug 20, 2026
Merged

feat(standards): Phase 1 lossless canonical standard layer + alignment audit#14
xianyu9n merged 4 commits into
masterfrom
feat/phase1-canonical-standard

Conversation

@xianyu9n

@xianyu9n xianyu9n commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

动机

把已确认的原始分类分级标准(finance 标准指南、shougang 关基目录)整理成统一、可审计、可复现的 canonical standard 事实层。不修改任何现有训练行为(prompt/parser/reward/SFT/RL、样本、registry/corpus 均不动)。

语义边界(Phase 0:docs/design/data_level_design.md)

classification / sample_data_level / standard_data_level 严格分离、不互相覆盖;field_sensitive 独立不处理;不推断 L1-L4 语义、不跨数据集假设同义;不把 level_4 槽位当作所有源都真实四层。

变更(3 commits)

  • src/agent/standards/:contracts(schema、指纹、训练投影)、merged-range-aware readers(MergedCellResolver + 列语义)、deterministic builders、只读对齐。
  • script/standard/cli.py + checksums.json:可重生成 + sha256 校验(restore 流程,raw 不进 Git)。
  • docs/design/phase1_canonical_standard.md:schema、列语义(hierarchy/leaf/scoped)、对齐统计、异常、迁移 note、restore。
  • tests/standards/:56 个(含 merger/resolver、J 作用域、样本源零合并)。

关键修复点

  1. 事实层不聚合:standard_entry_id(含真实三级)与 category_id(训练 alias)分离;finance 237 entries → training_projection → 233 categories;5 条合约协议条目逐条保留。
  2. merged-range-aware:finance 备注 J(J55=1 / J93:J132=40 / J168:J169=2)与部门意见 K 建模为 scoped_annotations;shougang 一级/二级/三级定义 + 数据来源(resource) 进 raw_fields 并带 source_cell/merged_range provenance。
  3. 顺带修正 stale-carry bug:账户信息 分支 5 条目过去被旧 reader 带入了上组三级"单位标签信息",现正确为"空三级"(与数据 level_3 为空一致)。
  4. 样本源零合并:部分金融数据(仅标题 A1:A2)/ 带分级分类 / 关基设施测试 均无业务级 merged cells,样本层零改动(已测)。
  5. pers_info 无标准 → 不生成 standard_data_level;infra 复用 shougang;检验 192/192、529/2/37、64/64 均复现。

对齐审计

dataset total resolved matched mismatched standard_missing match_rate
finance 568 531 529 2(AMONEY/HXTRADENO) 0 99.62%
shougang 19,415 18,393 18,393 0 0 100%
infra 64 64 64 0 0 100%

测试

pytest tests/standards56 passed;全仓 298 passed, 2 skipped(skip=本地无 verl,既有)。重复构建字节级一致。

未做(留给下一步)

  • 不改 registry/corpus 消费链(migration note 已列 Phase 2 改法)。
  • Stage2 是否把 standard_data_level / grading rules 暴露给模型(Phase 0 A/B)未预置。
  • alignment 的 exact/projection/ambiguous 细分与 training_categories 改名建议(评审待答复,可在后续 commit 带)。

曾立宏 added 2 commits August 20, 2026 14:02
…t audit

Build the ORIGINAL classification/grading standards (finance guide Excel,
shougang 关基 catalog Excel) into a lossless, auditable canonical form that
restores real hierarchy depth and grading columns the legacy standards_map
digests dropped. Adds Phase 0 semantics doc + Phase 1 design/migration note.

- src/agent/standards: contracts (StandardCategory/CanonicalStandard,
  standard_data_level kept separate from sample data_level), raw xlsx readers,
  deterministic builders, read-only sample<->standard alignment
- script/standard/cli: regenerable data/standards/*.standard.json +
  artifacts/generated/provenance/* (finance/shougang/infra alignments, summary)
- alignment facts: finance 529 matched / 2 outliers (AMONEY, HXTRADENO) /
  37 unresolved; shougang 18,393/18,393 (100%); infra 64/64; guanji_dict lost
  B3-6 中厚板作业计划 (documented, not fixed)
- tests/standards: 26 hermetic + real-xlsx integration tests (raw missing => skip)
- no training behavior change: no changes to prompts/parser/reward/SFT/RL,
  samples, registry/corpus, or data_level-as-target
… deterministic order

Addresses the Phase-1 review blocking items without touching training code.

- Blocker 1: one CanonicalStandard entry per real standard row (no fact-layer
  aggregation). standard_entry_id (finance L1.L2.l3.L4 / shougang code) is the
  true source identity; category_id is the training/registry alias; 237 finance
  entries project to 233 training categories via derived training_projection.
  The 5 same-alias 合约协议 entries are preserved with distinct 三级/path/source.
- Blocker 2 (option B): committed script/standard/checksums.json; CLI verifies
  raw-workbook sha256 before building and refuses on mismatch; restore/checksum
  flow documented in phase1_canonical_standard.md.
- P1: ReaderResult.issues are merged into the build report (reader_issue kind).
- P1: build report reports standard_entries_out (237/234) + training_categories
  (233/234); level distribution over final entries.
- P1: determinism now order-independent even for duplicate category_id entries
  (every entry preserved + sorted by standard_entry_id); tests added.
- Non-blocking: alignment unresolved_evidence (status/leaf_name/candidates)
  for the 37 finance non-trainable samples, evidence-only.
- tests/standards 37 passed; full suite 279 passed, 2 skipped (pre-existing).
@xianyu9n

Copy link
Copy Markdown
Collaborator Author

Review 修复(b20d2a0)已推送

按上轮 review 的 blockers 全部落地,未触碰任何训练代码。

Blocker 1:事实层不再聚合(237 无损)

  • 每个原始标准行 = 一个 standard_entry_id(finance 含真实三级:finance:{L1}.{L2}.{L3}.{L4};shougang = code)。
  • category_id(finance L1-L2-leaf)降为 training alias/投影,经顶层 training_projection 显式给出。
  • finance 237 entries / 233 training categories业务/合约协议/基本信息 的 5 条(合同通用/贷款业务/中间业务/资金业务/其他支付业务)全部保留(path/source 逐条),不再 first-wins 折叠。

Blocker 2:分发走 Option B(restore + checksum)

  • 已入库 script/standard/checksums.json(两张 raw workbook 的 sha256)。
  • CLI 构建前校验,缺失/不符直接拒绝(--skip-checksum 供离线显式绕过)。
  • restore/校验流程写入 docs/design/phase1_canonical_standard.md

P1 顺手修

  • ReaderResult.issues 并入 build report(reader_issue)。
  • build report 口径改为 standard_entries_out + training_categories(不再有 237/233 同字段矛盾)。
  • determinism 现在对同 category_id 的重复条目也顺序无关(逐 entry 保真 + 按 standard_entry_id 排序),并补了 5 条同 alias 乱序测试。
  • 非阻塞项:finance 37 条 unresolved 增加 evidence-only unresolved_evidence(status/leaf_name/candidate_standard_categories)。

验证

  • pytest tests/standards → 37 passed(新增 checksum + 多 entry alignment + 乱序 determinism)。
  • 全仓 279 passed, 2 skipped(既有 verl skip)。
  • 对齐数字不变:finance 529/2/37、shougang 18393/18393、infra 64/64;重复构建字节级一致。

…sless grid facts)

Standard sources use vertical cell merges for hierarchy/definition columns and
for grid annotations (finance 备注 J). This makes both standard readers
merged-range-aware and preserves the ORIGINAL scope, so group-level facts are
never misread as a single anchor leaf's private info. Standards layer only.

- MergedCellResolver: value + anchor_cell + merged_range + start/end row +
  inherited for any cell; readers drop manual carry-forward.
- finance columns: B/C (L1/L2) D (L2 def) E/F (L3, L3 def) G/H/I (leaf/
  desc/level) J remark K department_opinion.
- shougang columns: B..G (L1-3 + definitions) H/I (leaf/leaf def) J content
  K level L resource.
- entries gain raw_fields (inherited hierarchy definitions + resource) with
  source_cell/merged_range provenance (incl in fingerprint/round-trip).
- finance 备注 J becomes standard-level scoped_annotations: J55->1,
  J93:J132->40, J168:J169->2 reproduced and tested; K (empty) routed same way.
- shougang 三级定义 no longer assumed for leaf-at-三级 rows; definitions +
  resource kept with provenance.
- fixes a stale carry-forward bug: 账户信息 branch's 5 entries now correctly
  have EMPTY 三级 (the standard genuinely has none there), matching data's
  empty level_3.
- sample-source workbooks confirmed merge-free (finance sample has only the
  A1:A2 title merge); sample layer untouched.
- tests/standards 56 passed; full suite 298 passed, 2 skipped (pre-existing).
@xianyu9n

xianyu9n commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

已按上轮与新发现的'merged cells 组级语义'补 commit 3ddef8a:两个 standard reader 改 merged-range-aware(MergedCellResolver),finance 备注/部门意见建模为 scoped_annotations(J55=1 / J93:J132=40 / J168:J169=2 已复现并测),shougang 各级定义+数据来源带 provenance 进 raw_fields;顺带修了'账户信息'分支被旧 carry 污染的 stale 三级。样本层零改动(三个 sample source 已测无业务级合并)。standards 56 passed / 全仓 298 passed。

Two unmerged cells with identical text (merged_range=None) were grouped into
ONE annotation spanning both rows (e.g. 55..200), which breaks the lossless
scope contract. Group by (type, text, scope_key) where scope_key is the merged
range ('J93:J132') or the cell itself ('J55') for an unmerged cell.

- _scoped_annotations(): scope_key grouping; merged_range=None kept per cell
- _push_annotation_sighting(): type annotation corrected to 8 items
- shougang reader: guard empty 分级 cell (None -> '' instead of 'None')
- regression test: J5 + J10 same text, unmerged -> 2 annotations, each its row
- tests/standards 57 passed; full suite 299 passed, 2 skipped (pre-existing)
@xianyu9n

xianyu9n commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

fix 1b11a25: annotation 分组改用 scope_key(merged_range ?? source_cell)——未合并却同文字的独立格不再被并成跨行一条注解(J5+J10 同文→两条各管各行,回归已测)。顺手:shougang 空分级 None→'' 守卫、_push 类型标注 8 项修正。standards 57 passed / 全仓 299 passed。

@xianyu9n
xianyu9n merged commit 678be4c into master Aug 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant