Reject structurally broken OOXML at artifact registration #197

Merged
weichen merged 2 commits from feature/pptx-register-structural-gate into main 2026-10-14 08:36:19 +00:00
Owner

Why

Agent 绕开 housestyle kit 用 zipfile 手拼 OOXML 生成 pptx,产物缺母版/主题/docProps:正文抽取照常成功、既有校验全部放行,Office 按 OPC 校验才判损坏,残缺包作为交付物发到了用户手里。

What

  • 新增 internal/tools/ooxmlgate.go:登记口 L1 纯 Go OPC 结构自检(零依赖)——ZIP 合法、[Content_Types].xml 与正文部件存在且 XML 合法;pptx 校验 presentation 声明 sldMasterIdLst、slide→layout→master→theme 引用链逐级可达。
  • register_artifact 接线:结构残缺的 docx/xlsx/pptx 拒绝登记,报错含 housestyle kit 重建指引(登记被拒后终轮 ClaimGate 兜底拦截"已生成却无工件")。
  • housestyle/lint.py:lint_pptx 前置母版/主题/版式链断言(structure-broken,不随模板降级),打开失败兜底为结构错误而非 traceback。
  • 提示词:tool.run_python v2 / base.deliverables v8 禁止手拼 OOXML,缺库装不上时如实告知而非退回手拼。
  • fs_write_file 已有 rejectBinaryOfficeWrite 前置拦截,无需改动。

Evidence

  • Go:ooxmlgate_test.go 合法/事故形复刻/九类断链/登记集成;runmgr 回填契约夹具改为结构合法 docx 后复验通过(go vet 过)。
  • Python:test_housestyle.BrokenPptxTests 3 项 + 全套 12 项过;事故形包 lint 报 structure-broken(exit 1),kit 产物干净。
  • 组合验证本地全绿一次(07:47,含全部代码改动);scripts/svc 治理段在本机负载下逐轮漂移 flake(与改动无代码交集,单测必过),以 CI 为 GATE 权威。
  • 逐条收据见 Dev 仓任务卡 feature/pptx-register-structural-gate 证据表(SELF,CI 复核后升级)。

Impact

  • 合法 kit 产物登记行为不变;手拼残缺包在登记口被拒。工件面板、检索索引不受影响。
  • B3(agent-native gates scorer 白名单扩面)另行任务,不在本 PR。

Refs

  • Dev 任务分支 feature/pptx-register-structural-gate(含 Dev pin bump 组合 PR)
## Why Agent 绕开 housestyle kit 用 zipfile 手拼 OOXML 生成 pptx,产物缺母版/主题/docProps:正文抽取照常成功、既有校验全部放行,Office 按 OPC 校验才判损坏,残缺包作为交付物发到了用户手里。 ## What - 新增 `internal/tools/ooxmlgate.go`:登记口 L1 纯 Go OPC 结构自检(零依赖)——ZIP 合法、`[Content_Types].xml` 与正文部件存在且 XML 合法;pptx 校验 presentation 声明 `sldMasterIdLst`、slide→layout→master→theme 引用链逐级可达。 - `register_artifact` 接线:结构残缺的 docx/xlsx/pptx 拒绝登记,报错含 housestyle kit 重建指引(登记被拒后终轮 ClaimGate 兜底拦截"已生成却无工件")。 - `housestyle/lint.py`:`lint_pptx` 前置母版/主题/版式链断言(`structure-broken`,不随模板降级),打开失败兜底为结构错误而非 traceback。 - 提示词:`tool.run_python` v2 / `base.deliverables` v8 禁止手拼 OOXML,缺库装不上时如实告知而非退回手拼。 - `fs_write_file` 已有 `rejectBinaryOfficeWrite` 前置拦截,无需改动。 ## Evidence - Go:`ooxmlgate_test.go` 合法/事故形复刻/九类断链/登记集成;runmgr 回填契约夹具改为结构合法 docx 后复验通过(`go vet` 过)。 - Python:`test_housestyle.BrokenPptxTests` 3 项 + 全套 12 项过;事故形包 lint 报 structure-broken(exit 1),kit 产物干净。 - 组合验证本地全绿一次(07:47,含全部代码改动);scripts/svc 治理段在本机负载下逐轮漂移 flake(与改动无代码交集,单测必过),以 CI 为 GATE 权威。 - 逐条收据见 Dev 仓任务卡 `feature/pptx-register-structural-gate` 证据表(SELF,CI 复核后升级)。 ## Impact - 合法 kit 产物登记行为不变;手拼残缺包在登记口被拒。工件面板、检索索引不受影响。 - B3(agent-native gates scorer 白名单扩面)另行任务,不在本 PR。 ## Refs - Dev 任务分支 `feature/pptx-register-structural-gate`(含 Dev pin bump 组合 PR)
weichen added 2 commits 2026-10-14 08:30:16 +00:00
Why: An agent bypassing the housestyle kit hand-assembled OOXML with
zipfile; the resulting pptx lacked masters, theme and docProps. Text
extraction succeeded and every existing check passed, so a package that
Office refuses to open reached the user as a deliverable.

Evidence: Focused Go suite covers a valid minimal pptx, the incident-
shaped package, nine chain-break variants and register-level integration;
the housestyle python suite adds BrokenPptxTests for masterless, kit-made
and unopenable files. Full combined suite receipt follows on the task
card before review.

Impact: register_artifact now runs a pure-Go OPC structural check for
docx/xlsx/pptx and refuses broken packages with a kit rebuild hint;
lint_pptx gains structure-broken assertions (master/theme/layout chain,
open-failure fallback) that template mode cannot downgrade; prompts
forbid hand-assembled OOXML and specify the missing-library fallback.

Refs: Dev task feature/pptx-register-structural-gate
Make artifact backfill fixture a structurally valid docx
ci / vet-and-test (pull_request) Successful in 1m16s
c8f8076579
Why: The backfill contract test used a fake PK-magic docx as its fixture;
the new registration structural gate correctly refuses that shape, so the
contract was no longer exercised.

Evidence: The three affected runmgr tests pass locally with -count=1;
the full combined suite receipt follows on the task card.

Impact: Test fixture only; the gate behavior under test is unchanged.

Refs: Dev task feature/pptx-register-structural-gate
weichen merged commit 607c38d7e6 into main 2026-10-14 08:36:19 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Backend#197