report-workflow 4.41.1__tar.gz → 4.41.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. {report_workflow-4.41.1 → report_workflow-4.41.2}/CHANGELOG.md +12 -0
  2. {report_workflow-4.41.1 → report_workflow-4.41.2}/PKG-INFO +10 -7
  3. {report_workflow-4.41.1 → report_workflow-4.41.2}/README.md +9 -6
  4. {report_workflow-4.41.1 → report_workflow-4.41.2}/pyproject.toml +1 -1
  5. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/SKILL.md +3 -1
  6. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/authoring.md +4 -1
  7. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/__init__.py +1 -1
  8. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/proposal.yaml +12 -2
  9. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/derived_evidence.py +14 -2
  10. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/agent_tasks.py +1 -1
  11. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/citation_bind.py +40 -0
  12. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/claim_plan.py +13 -0
  13. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/docx_render.py +131 -4
  14. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/factuality_check.py +168 -35
  15. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/figure_build.py +7 -1
  16. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/figure_recommend.py +93 -0
  17. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/heading_contract_check.py +20 -3
  18. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/outline_plan.py +24 -0
  19. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/post_render_validate.py +6 -3
  20. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/section_contract.py +4 -3
  21. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/section_draft.py +4 -2
  22. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/source_tables.py +98 -3
  23. report_workflow-4.41.2/src/report_workflow/quote_gate.py +90 -0
  24. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/reference_match.py +111 -8
  25. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/source_citation.py +18 -2
  26. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow.egg-info/PKG-INFO +10 -7
  27. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow.egg-info/SOURCES.txt +3 -0
  28. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_calculation_record.py +2 -2
  29. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_chinese_quantity_expressions.py +23 -0
  30. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_declared_source_citations.py +30 -0
  31. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_delivered_layout.py +12 -0
  32. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_document_language.py +9 -9
  33. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_evidence_traceability.py +36 -0
  34. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_figure_recommend.py +46 -0
  35. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_format_standards.py +93 -0
  36. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_hallucination_gate.py +47 -0
  37. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_intake_summary_measures.py +15 -0
  38. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_mvp_workflow.py +44 -0
  39. report_workflow-4.41.2/tests/test_quote_gate.py +45 -0
  40. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_raw_data_reports.py +24 -0
  41. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_reference_match.py +92 -0
  42. report_workflow-4.41.2/tests/test_small_issues_2026_11_17.py +164 -0
  43. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_structured_draft_paragraphs.py +9 -0
  44. {report_workflow-4.41.1 → report_workflow-4.41.2}/.env.example +0 -0
  45. {report_workflow-4.41.1 → report_workflow-4.41.2}/LICENSE +0 -0
  46. {report_workflow-4.41.1 → report_workflow-4.41.2}/MANIFEST.in +0 -0
  47. {report_workflow-4.41.1 → report_workflow-4.41.2}/requirements.txt +0 -0
  48. {report_workflow-4.41.1 → report_workflow-4.41.2}/setup.cfg +0 -0
  49. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/benchmarking.md +0 -0
  50. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/engineering-lab.md +0 -0
  51. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/figures.md +0 -0
  52. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/profiles.md +0 -0
  53. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/revision.md +0 -0
  54. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/setup-and-preflight.md +0 -0
  55. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/reference/tools.md +0 -0
  56. {report_workflow-4.41.1 → report_workflow-4.41.2}/skills/report-workflow/skill.yaml +0 -0
  57. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/__main__.py +0 -0
  58. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/agent_wrapper.py +0 -0
  59. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/artifact_contract.py +0 -0
  60. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/artifact_lint.py +0 -0
  61. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/artifact_packaging/__init__.py +0 -0
  62. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/artifact_packaging/common.py +0 -0
  63. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/artifact_packaging/final_qa.py +0 -0
  64. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/artifact_packaging/template_reports.py +0 -0
  65. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/automation_harness.py +0 -0
  66. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/__init__.py +0 -0
  67. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/academic_paper.yaml +0 -0
  68. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/admissions_project_report.yaml +0 -0
  69. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/admissions_report.yaml +0 -0
  70. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/business_report.yaml +0 -0
  71. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/custom.yaml +0 -0
  72. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/engineering_lab_report.yaml +0 -0
  73. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/blueprints/quant_research_memo.yaml +0 -0
  74. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/cli.py +0 -0
  75. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/config.py +0 -0
  76. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/__init__.py +0 -0
  77. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/banned_phrases.json +0 -0
  78. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/governance_policy.json +0 -0
  79. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/guideline_rules.json +0 -0
  80. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/style_profiles/academic.json +0 -0
  81. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/style_profiles/hybrid.json +0 -0
  82. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/style_profiles/work.json +0 -0
  83. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/configs/style_vocab.json +0 -0
  84. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/connectors/__init__.py +0 -0
  85. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/connectors/notebooklm_connector.py +0 -0
  86. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/connectors/research_backends.py +0 -0
  87. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/draft_check.py +0 -0
  88. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/engineering_audit.py +0 -0
  89. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/errors.py +0 -0
  90. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/CHINESE_ENGINEERING.json +0 -0
  91. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/CONSORT.json +0 -0
  92. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/PRISMA.json +0 -0
  93. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/SRQR.json +0 -0
  94. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/STARD.json +0 -0
  95. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/STROBE.json +0 -0
  96. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/guidelines/TRIPOD.json +0 -0
  97. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/language.py +0 -0
  98. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/mcp_server.py +0 -0
  99. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/__init__.py +0 -0
  100. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/abstract_check.py +0 -0
  101. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/admissions_monograph_polish.py +0 -0
  102. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/admissions_tone_gate.py +0 -0
  103. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/artifacts.py +0 -0
  104. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/base_document_diff.py +0 -0
  105. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/base_document_parse.py +0 -0
  106. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/blueprint_plan.py +0 -0
  107. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/cited_sources.py +0 -0
  108. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/claim_verify_execute.py +0 -0
  109. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/corpus_build.py +0 -0
  110. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/derived_evidence.py +0 -0
  111. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/evidence_normalize.py +0 -0
  112. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/evidence_store.py +0 -0
  113. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/figure_plan_audit.py +0 -0
  114. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/figure_quality.py +0 -0
  115. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/figure_types.py +0 -0
  116. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/figure_utils.py +0 -0
  117. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/final_publish.py +0 -0
  118. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/front_matter_build.py +0 -0
  119. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/guideline_select.py +0 -0
  120. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/heading_dedup.py +0 -0
  121. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/intake.py +0 -0
  122. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/merge_draft.py +0 -0
  123. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/methods_protocol_build.py +0 -0
  124. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/notebook_sync.py +0 -0
  125. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/paper_scope_freeze.py +0 -0
  126. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/post_render_repair.py +0 -0
  127. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/project_identity_gate.py +0 -0
  128. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/publication_naturalness_pass.py +0 -0
  129. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/qa_gate.py +0 -0
  130. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/reference_reality_check.py +0 -0
  131. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/reference_relevance_gate.py +0 -0
  132. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/reference_verify.py +0 -0
  133. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/register_gate.py +0 -0
  134. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/remediation_router.py +0 -0
  135. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/research_execute.py +0 -0
  136. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/revision_apply.py +0 -0
  137. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/section_plan_freeze.py +0 -0
  138. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/section_role_check.py +0 -0
  139. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/source_appendix_render.py +0 -0
  140. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/source_parse.py +0 -0
  141. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/style_pass.py +0 -0
  142. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/supplementary_package_build.py +0 -0
  143. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/table_transform.py +0 -0
  144. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/nodes/visual_render_check.py +0 -0
  145. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/__init__.py +0 -0
  146. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/agent_fallback.py +0 -0
  147. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/code_parser.py +0 -0
  148. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/office_math.py +0 -0
  149. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/semi_structured_parser.py +0 -0
  150. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/source_text.py +0 -0
  151. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/parsers/structured_parser.py +0 -0
  152. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/policies/__init__.py +0 -0
  153. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/policies/policy_pack.py +0 -0
  154. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/preflight.py +0 -0
  155. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/preflight_decisions.py +0 -0
  156. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/profiles.py +0 -0
  157. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/prompt_questions.py +0 -0
  158. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/prompts/__init__.py +0 -0
  159. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/prompts/intake_prompt.py +0 -0
  160. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/reference_list.py +0 -0
  161. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/run_workflow.py +0 -0
  162. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/runtime_support.py +0 -0
  163. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/source_selection.py +0 -0
  164. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/state.py +0 -0
  165. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/templates/reference.docx +0 -0
  166. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/validators/__init__.py +0 -0
  167. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/validators/parse_validator.py +0 -0
  168. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow/verify.py +0 -0
  169. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow.egg-info/dependency_links.txt +0 -0
  170. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow.egg-info/entry_points.txt +0 -0
  171. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow.egg-info/requires.txt +0 -0
  172. {report_workflow-4.41.1 → report_workflow-4.41.2}/src/report_workflow.egg-info/top_level.txt +0 -0
  173. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_adversarial_benchmark.py +0 -0
  174. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_append_only_ledger_contract.py +0 -0
  175. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_automation_harness.py +0 -0
  176. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_benchmark_contracts.py +0 -0
  177. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_check_draft.py +0 -0
  178. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_cited_sources.py +0 -0
  179. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_column_roles.py +0 -0
  180. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_decimal_comma_evidence.py +0 -0
  181. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_declared_citation_propagation.py +0 -0
  182. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_delivered_attributions.py +0 -0
  183. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_delivery_contracts.py +0 -0
  184. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_docx_render_references.py +0 -0
  185. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_emission_intensity_units.py +0 -0
  186. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_external_benchmark.py +0 -0
  187. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_fe_names_the_span_it_read.py +0 -0
  188. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_figure_recommendation_loss.py +0 -0
  189. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_figure_value_support.py +0 -0
  190. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_form_feed_line_numbers.py +0 -0
  191. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_formula_derivations.py +0 -0
  192. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_grouped_derived_evidence.py +0 -0
  193. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_improvements.py +0 -0
  194. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_line_chart_markers.py +0 -0
  195. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_long_block_evidence.py +0 -0
  196. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_mcp_server.py +0 -0
  197. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_measurement_and_union_rule.py +0 -0
  198. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_mermaid.py +0 -0
  199. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_naturalness_machine_tells.py +0 -0
  200. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_outline_brief_lists_required_sections.py +0 -0
  201. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_outline_obligations.py +0 -0
  202. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_pdf_inline_scripts.py +0 -0
  203. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_pdf_table_cells.py +0 -0
  204. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_quant_research_memo_profile.py +0 -0
  205. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_reference_list.py +0 -0
  206. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_register_gate.py +0 -0
  207. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_report_axes.py +0 -0
  208. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_report_quality_benchmark.py +0 -0
  209. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_revision_change_types.py +0 -0
  210. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_revision_diff.py +0 -0
  211. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_roadmap_contracts.py +0 -0
  212. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_scientific_notation_evidence.py +0 -0
  213. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_source_selection.py +0 -0
  214. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_state_checkpoint.py +0 -0
  215. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_structured_source_tables.py +0 -0
  216. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_table_display_precision.py +0 -0
  217. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_trend_claims.py +0 -0
  218. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_usability_audit_2026_10_19.py +0 -0
  219. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_usability_consolidated_2026_10_21.py +0 -0
  220. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_usability_review_2026_10_20.py +0 -0
  221. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_usability_round3_2026_10_20.py +0 -0
  222. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_verify_adapter.py +0 -0
  223. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_version_sync.py +0 -0
  224. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_visual_review_status.py +0 -0
  225. {report_workflow-4.41.1 → report_workflow-4.41.2}/tests/test_wide_table_landscape.py +0 -0
  226. {report_workflow-4.41.1 → report_workflow-4.41.2}/workflow_config.yaml +0 -0
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.41.2 - 2026-11-18
4
+
5
+ Six small fixes found by writing reports end to end; no gate, profile or public
6
+ option changes.
7
+
8
+ - FE no longer reads figure/table labels (圖 2, 表 1, Figure 2) or 筆電 as quantities.
9
+ - A complete two-parameter grid (one row per cell) is recommended as a heatmap, and
10
+ the build-time density check uses the recommender's own 16 x 12 ceiling.
11
+ - A Chinese document numbers first-level headings 一、二、三、 instead of 1. 2. 3.
12
+ - A pipe table the author typed gets a numbered caption, 表 N. 標題.
13
+ - Test count 1490.
14
+
3
15
  ## 4.41.1 - 2026-10-22
4
16
 
5
17
  Three usability passes on the same question — what stops an author between
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: report-workflow
3
- Version: 4.41.1
3
+ Version: 4.41.2
4
4
  Summary: Turn sources into a submission-ready report, with deterministic gates that block any claim not traceable to the evidence.
5
5
  Author-email: 0Smallcat0 <noiroao@gmail.com>
6
6
  License-Expression: MIT
@@ -53,7 +53,7 @@ mcp-name: io.github.0Smallcat0/report-workflow
53
53
 
54
54
  [![CI](https://github.com/0Smallcat0/report-workflow/actions/workflows/ci.yml/badge.svg)](https://github.com/0Smallcat0/report-workflow/actions/workflows/ci.yml)
55
55
  ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
56
- ![Tests](https://img.shields.io/badge/tests-1439%20passing-brightgreen)
56
+ ![Tests](https://img.shields.io/badge/tests-1490%20passing-brightgreen)
57
57
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
58
58
 
59
59
  **繁體中文說明 → [README.zh-TW.md](README.zh-TW.md)**
@@ -149,7 +149,9 @@ installed: `uvx report-workflow check-references draft.docx`.
149
149
 
150
150
  It reads `.docx`, `.md`, `.txt` and `.bib`. Each DOI is looked up at doi.org
151
151
  (which also carries retraction notices), each arXiv id at arXiv, and a reference
152
- with neither is searched for in Crossref and OpenAlex. No API key, no account,
152
+ with neither is searched for in Crossref and OpenAlex; when that settles
153
+ nothing and the reference links a web page (a statute, a course, a news
154
+ story), the page is opened and its own title looked for in the reference. No API key, no account,
153
155
  and no AI deciding anything: the same file gets the same verdicts.
154
156
 
155
157
  A five-reference draft with four errors planted in it:
@@ -183,7 +185,7 @@ references here:
183
185
 
184
186
  | Checker | Problem references caught (of 33) | Correct references flagged (of 71) |
185
187
  | --- | ---: | ---: |
186
- | **report-workflow** | **30** | **15** |
188
+ | **report-workflow** | **30** | **10** |
187
189
  | RefChecker | 32 | 36 |
188
190
  | CheckIfExist | 31 | 34 |
189
191
  | Hallucinator | 29 | 28 |
@@ -191,9 +193,10 @@ references here:
191
193
  | HalRef | 24 | 53 |
192
194
 
193
195
  "Flagged" counts anything short of accepted — for the five tools that includes
194
- "requires verification", here it is every verdict except `verified`. All 15 of
195
- those here are `needs_review`, and seven of them are standards, software, datasets,
196
- model cards and workshop pages that no bibliographic registry holds. Of the 13
196
+ "requires verification", here it is every verdict except `verified`. All 10 of
197
+ those here are `needs_review`; three are a standard, a software repository and a
198
+ model card that no bibliographic registry holds and whose pages title them
199
+ differently from the reference. Of the 13
197
200
  references it called `mismatch`, `not_found` or `retracted`, every one is wrong
198
201
  in the hand-checked labels. The three it passes cite the wrong venue or the
199
202
  wrong first name, which it does not compare.
@@ -11,7 +11,7 @@ mcp-name: io.github.0Smallcat0/report-workflow
11
11
 
12
12
  [![CI](https://github.com/0Smallcat0/report-workflow/actions/workflows/ci.yml/badge.svg)](https://github.com/0Smallcat0/report-workflow/actions/workflows/ci.yml)
13
13
  ![Python](https://img.shields.io/badge/python-3.11%2B-blue)
14
- ![Tests](https://img.shields.io/badge/tests-1439%20passing-brightgreen)
14
+ ![Tests](https://img.shields.io/badge/tests-1490%20passing-brightgreen)
15
15
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
16
16
 
17
17
  **繁體中文說明 → [README.zh-TW.md](README.zh-TW.md)**
@@ -107,7 +107,9 @@ installed: `uvx report-workflow check-references draft.docx`.
107
107
 
108
108
  It reads `.docx`, `.md`, `.txt` and `.bib`. Each DOI is looked up at doi.org
109
109
  (which also carries retraction notices), each arXiv id at arXiv, and a reference
110
- with neither is searched for in Crossref and OpenAlex. No API key, no account,
110
+ with neither is searched for in Crossref and OpenAlex; when that settles
111
+ nothing and the reference links a web page (a statute, a course, a news
112
+ story), the page is opened and its own title looked for in the reference. No API key, no account,
111
113
  and no AI deciding anything: the same file gets the same verdicts.
112
114
 
113
115
  A five-reference draft with four errors planted in it:
@@ -141,7 +143,7 @@ references here:
141
143
 
142
144
  | Checker | Problem references caught (of 33) | Correct references flagged (of 71) |
143
145
  | --- | ---: | ---: |
144
- | **report-workflow** | **30** | **15** |
146
+ | **report-workflow** | **30** | **10** |
145
147
  | RefChecker | 32 | 36 |
146
148
  | CheckIfExist | 31 | 34 |
147
149
  | Hallucinator | 29 | 28 |
@@ -149,9 +151,10 @@ references here:
149
151
  | HalRef | 24 | 53 |
150
152
 
151
153
  "Flagged" counts anything short of accepted — for the five tools that includes
152
- "requires verification", here it is every verdict except `verified`. All 15 of
153
- those here are `needs_review`, and seven of them are standards, software, datasets,
154
- model cards and workshop pages that no bibliographic registry holds. Of the 13
154
+ "requires verification", here it is every verdict except `verified`. All 10 of
155
+ those here are `needs_review`; three are a standard, a software repository and a
156
+ model card that no bibliographic registry holds and whose pages title them
157
+ differently from the reference. Of the 13
155
158
  references it called `mismatch`, `not_found` or `retracted`, every one is wrong
156
159
  in the hand-checked labels. The three it passes cite the wrong venue or the
157
160
  wrong first name, which it does not compare.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "report-workflow"
7
- version = "4.41.1"
7
+ version = "4.41.2"
8
8
  description = "Turn sources into a submission-ready report, with deterministic gates that block any claim not traceable to the evidence."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -70,7 +70,9 @@ supports:
70
70
  ```
71
71
 
72
72
  CLI exit codes: `0` success, `1` crash, `2` hard-block validation failure,
73
- `3` waiting for user decisions or agent-authored artifacts. Full signatures and
73
+ `3` waiting for user decisions or agent-authored artifacts. A `prepare` that
74
+ ends at `awaiting_agent_artifacts` exits `0`: writing the briefs is its job; `3`
75
+ comes from `validate`/`run` called before those artifacts exist. Full signatures and
74
76
  parameters: [reference/tools.md](reference/tools.md).
75
77
 
76
78
  ## Required Setup
@@ -286,7 +286,10 @@ canonical Chinese section headings; the pipeline detects the document language
286
286
  deterministically and renders section headings from the blueprint's localized
287
287
  titles (`title_zh`), so do not hand-translate headings or mix English
288
288
  boilerplate sentences into a Chinese document. English documents keep the
289
- blueprint's English titles unchanged.
289
+ blueprint's English titles unchanged. When a competition or grant form fixes
290
+ the chapter names, set `"title"` on that section in `outline.json`
291
+ (`"problem_statement": {"title": "原創性說明", ...}`); it replaces the blueprint
292
+ heading in either language.
290
293
 
291
294
  For `academic_paper` and `engineering_lab_report`, make Methods/Procedure
292
295
  reproducible: name the source or sample basis, procedure, parameters or
@@ -1,5 +1,5 @@
1
1
  # Report Workflow: deterministic source-to-report pipeline
2
- __version__ = "4.41.1"
2
+ __version__ = "4.41.2"
3
3
 
4
4
  from .verify import verify
5
5
 
@@ -19,6 +19,7 @@ section_order:
19
19
  - budget_resources
20
20
  - risks
21
21
  - evaluation
22
+ - team
22
23
  - appendix
23
24
  - references
24
25
 
@@ -86,13 +87,22 @@ sections:
86
87
  required: false
87
88
  section_type: evaluation
88
89
  order: 9
90
+ # Who does what. Grant calls and competition forms ask for it; it states
91
+ # facts about the authors, so it cites nothing.
92
+ team:
93
+ section_id: team
94
+ title: Team and Roles
95
+ title_zh: 團隊與分工
96
+ required: false
97
+ section_type: team
98
+ order: 10
89
99
  appendix:
90
100
  section_id: appendix
91
101
  title: Appendix
92
102
  title_zh: 附錄
93
103
  required: false
94
104
  section_type: appendix
95
- order: 10
105
+ order: 11
96
106
  # Generated from the evidence ledger by CITATION_BIND and appended at
97
107
  # render; the author writes nothing here.
98
108
  references:
@@ -101,4 +111,4 @@ sections:
101
111
  title_zh: 參考文獻
102
112
  required: false
103
113
  section_type: references
104
- order: 11
114
+ order: 12
@@ -68,6 +68,18 @@ _ID_COLUMN_RE = re.compile(
68
68
  #: km had its "數值" column averaged to 4,695.72 and offered as citable.
69
69
  _UNIT_COLUMN_RE = re.compile(r"^(?:單位|单位|計量單位|计量单位|units?|uom|unit of measure)$", re.IGNORECASE)
70
70
 
71
+
72
+ def is_unit_column(column: object) -> bool:
73
+ """A unit column labels the value beside it; it is not a category.
74
+
75
+ A metric sheet with "%" on five rows and "秒" on two was summarised as
76
+ "單位 欄共 2 個相異值 … HHI 為 5918" and crossed into a "單位 分組交叉表"
77
+ the outline then had to place or waive. How many rows are measured in
78
+ seconds says nothing about anything the rows measure.
79
+ """
80
+ return bool(_UNIT_COLUMN_RE.match(str(column).strip()))
81
+
82
+
71
83
  #: A column of calendar years. Its mean is not a quantity ("年份 平均 2,015.00")
72
84
  #: and a year printed as "2,025" is not how anyone writes one; grouped by, it
73
85
  #: is a category.
@@ -2368,7 +2380,7 @@ def dataset_summary_units(
2368
2380
  (shape_content, shape_derivation, None)
2369
2381
  ]
2370
2382
  for column in dataset.columns[:MAX_COLUMNS_SUMMARIZED]:
2371
- if _ID_COLUMN_RE.search(str(column)):
2383
+ if _ID_COLUMN_RE.search(str(column)) or is_unit_column(column):
2372
2384
  continue
2373
2385
  values = dataset.column_values(column)
2374
2386
  filled = [value for value in values if str(value).strip()]
@@ -2430,7 +2442,7 @@ def _column_kinds(dataset: Dataset) -> tuple[list[str], list[str]]:
2430
2442
  categorical: list[tuple[int, int, str]] = []
2431
2443
  numeric: list[str] = []
2432
2444
  for column in dataset.columns[:MAX_COLUMNS_SUMMARIZED]:
2433
- if _ID_COLUMN_RE.search(str(column)):
2445
+ if _ID_COLUMN_RE.search(str(column)) or is_unit_column(column):
2434
2446
  continue
2435
2447
  values = dataset.column_values(column)
2436
2448
  filled = [value for value in values if str(value).strip()]
@@ -1517,7 +1517,7 @@ Use this deterministic chart-selection guidance when deciding `figure_ids` and f
1517
1517
 
1518
1518
  {outline_obligations}## Hard Rules
1519
1519
  - Assign every claim to at least one non-reference/non-appendix section.
1520
- - Use only section IDs defined by the blueprint.
1520
+ - Use only section IDs defined by the blueprint. When the user's form fixes a chapter name, set that section's `"title"`; it replaces the blueprint heading.
1521
1521
  - Use only claim IDs from `claim_matrix.json`.
1522
1522
  {results_mode_rule}{thesis_rule}{front_matter_rule}
1523
1523
  - The outline should create a real argument path: problem/gap/objective before methods, results before interpretation, and limitations before conclusion.
@@ -599,6 +599,43 @@ def merge_adjacent_trace_labels(text: str) -> str:
599
599
  return _CITATION_RUN_RE.sub(merge, text)
600
600
 
601
601
 
602
+ #: The date of an APA entry that carries a disambiguating letter:
603
+ #: 謝怡璇(2026b)。, Bellini, E. (2026b)., 環境部(無日期-a)。, DOE. (n.d.-a).
604
+ _SUFFIXED_DATE_RE = re.compile(r"[((](\d{4}|n\.d\.|無日期)-?([a-z])[))]")
605
+
606
+
607
+ def drop_unpaired_year_suffixes(body: str, refs: list[str]) -> tuple[str, list[str]]:
608
+ """A 2026b whose 2026a is not in the reference list loses its letter.
609
+
610
+ The letter tells apart two works by one author in one year, and authors
611
+ declare it across their whole source set. When only one of the pair is
612
+ cited, the published text read "謝怡璇,2026b" against a list with no
613
+ 2026a — to a reader, a missing entry. The letter is dropped from the entry
614
+ and from the in-text citations that name the same author.
615
+ """
616
+ groups: dict[tuple[str, str], list[int]] = {}
617
+ for index, ref in enumerate(refs):
618
+ match = _SUFFIXED_DATE_RE.search(ref)
619
+ if match:
620
+ author = ref[:match.start()].strip().rstrip(".")
621
+ groups.setdefault((author, match.group(1)), []).append(index)
622
+ refs = list(refs)
623
+ for (author, base), indices in groups.items():
624
+ if len(indices) != 1:
625
+ continue
626
+ ref = refs[indices[0]]
627
+ match = _SUFFIXED_DATE_RE.search(ref)
628
+ suffixed = match.group(0)[1:-1]
629
+ refs[indices[0]] = ref[:match.start() + 1] + base + ref[match.end() - 1:]
630
+ name = re.split(r"[,,、]", author)[0].strip()
631
+ body = re.sub(
632
+ rf"({re.escape(name)}[^()();;\n]{{0,40}}?(?:[,,]\s*|[((])){re.escape(suffixed)}(?![a-z])",
633
+ lambda m: m.group(1) + base,
634
+ body,
635
+ )
636
+ return body, refs
637
+
638
+
602
639
  _UNIT_HEADER_RE = re.compile(r"^(?:單位|单位|計量單位|计量单位|units?|uom)$", re.IGNORECASE)
603
640
  _SOURCE_HEADER_RE = re.compile(r"(?:出處|出处|來源|来源|source|reference|citation)", re.IGNORECASE)
604
641
 
@@ -1648,6 +1685,9 @@ def run_citation_bind(state: ReportState) -> ReportState:
1648
1685
  seen_refs.add(entry.strip().casefold())
1649
1686
  literature_refs.append(entry)
1650
1687
 
1688
+ if citation_style != "gb_t_7714_2015":
1689
+ stripped_md, literature_refs = drop_unpaired_year_suffixes(stripped_md, literature_refs)
1690
+
1651
1691
  publication_refs_md = ""
1652
1692
  if literature_refs and citation_style == "gb_t_7714_2015":
1653
1693
  publication_refs_md = f"{REFERENCE_LIST_HEADING}\n\n"
@@ -15,6 +15,7 @@ from ..state import ReportState
15
15
  from ..policies import get_policy
16
16
  from ..artifact_contract import load_jsonl_without_contract, make_artifact_contract, validate_artifact_contract, write_artifact_contract
17
17
  from ..artifact_contract import validate_evidence_ledger_provenance
18
+ from ..quote_gate import degrade_claims, ledger_quote_problems, record_attempt
18
19
  from .agent_tasks import missing_agent_artifacts, write_agent_task_briefs
19
20
 
20
21
 
@@ -194,6 +195,18 @@ def run_claim_plan(state: ReportState) -> ReportState:
194
195
  )
195
196
  _refuse_what_fa_will_refuse(claims, evidence_path)
196
197
  validate_evidence_ledger_provenance(evidence_path)
198
+ quote_problems = ledger_quote_problems(load_jsonl_without_contract(evidence_path))
199
+ gate = record_attempt(run_dir_for(state), quote_problems)
200
+ if gate["status"] == "retry":
201
+ raise QAHardBlockError(
202
+ "evidence_ledger.jsonl rows are not contiguous verbatim source text: "
203
+ + "; ".join(f"{k}: {v}" for k, v in list(quote_problems.items())[:8])
204
+ + ". Re-run prepare so the ledger is rebuilt from the sources; a second "
205
+ "failure falls back to a statistics-only report."
206
+ )
207
+ if gate["status"] == "stats_only":
208
+ claims, dropped = degrade_claims(claims, quote_problems)
209
+ gate["dropped_claims"] = dropped
197
210
  state.plan["claim_matrix"] = {"claims": claims}
198
211
  state.plan["claim_matrix_path"] = write_json_artifact(state, "claim_matrix.json", state.plan["claim_matrix"])
199
212
  write_artifact_contract(state.plan["claim_matrix_path"], make_artifact_contract(state))
@@ -6,6 +6,7 @@ Fallback path: python-docx regex-based converter (legacy).
6
6
  The pandoc path uses a reference.docx template for consistent academic styling
7
7
  (A4, Times New Roman 12pt, heading styles, 1.5x line spacing).
8
8
  """
9
+ import copy
9
10
  import json
10
11
  import logging
11
12
  import re
@@ -20,6 +21,7 @@ from docx.shared import Pt, Inches
20
21
  from docx.enum.text import WD_ALIGN_PARAGRAPH
21
22
  from docx.oxml.ns import qn
22
23
  from docx.oxml import OxmlElement
24
+ from lxml import etree
23
25
 
24
26
  from ..state import ReportState, WORKFLOW_RUNS_DIR
25
27
  from ..errors import QAHardBlockError
@@ -31,7 +33,7 @@ from .citation_bind import (
31
33
  SOURCE_LIST_INTRO,
32
34
  SOURCE_LIST_INTRO_ZH,
33
35
  )
34
- from .source_tables import replace_table_placeholders
36
+ from .source_tables import caption_author_tables, replace_table_placeholders
35
37
  from ..runtime_support import PLACEHOLDER_TEXT, load_jsonl
36
38
  from ..policies import get_policy
37
39
 
@@ -638,6 +640,74 @@ def _resolve_reference_doc(spec: dict) -> Path:
638
640
  return path
639
641
 
640
642
 
643
+ def _with_pandoc_styles(template: Path, dest: Path) -> Path:
644
+ """Write `template` to `dest` with the styles pandoc needs that it lacks.
645
+
646
+ A competition or course template is usually formatted by hand and defines
647
+ no heading, caption, or body-text styles. pandoc points every heading at
648
+ `Heading1`, finds no such style in the template, and Word shows the
649
+ heading as body text: the table of contents comes up empty and the
650
+ figure captions are plain paragraphs. The missing styles are copied from
651
+ the built-in reference; every style the template does define is left as
652
+ it is, so its fonts and spacing still win.
653
+ """
654
+ def styles_of(path: Path):
655
+ with zipfile.ZipFile(path) as archive:
656
+ return etree.fromstring(archive.read("word/styles.xml"))
657
+
658
+ def name_of(style) -> str:
659
+ name = style.find(qn("w:name"))
660
+ return (name.get(qn("w:val")) if name is not None else "").lower()
661
+
662
+ ours, base = styles_of(template), styles_of(_REFERENCE_DOC)
663
+ ours_styles = ours.findall(qn("w:style"))
664
+ have_ids = {style.get(qn("w:styleId")) for style in ours_styles}
665
+ id_by_name = {name_of(style): style.get(qn("w:styleId")) for style in ours_styles}
666
+ base_name_by_id = {style.get(qn("w:styleId")): name_of(style) for style in base.findall(qn("w:style"))}
667
+ added = [
668
+ copy.deepcopy(style) for style in base.findall(qn("w:style"))
669
+ if style.get(qn("w:styleId")) not in have_ids and name_of(style) not in id_by_name
670
+ ]
671
+ if not added:
672
+ return template
673
+ added_ids = {style.get(qn("w:styleId")) for style in added}
674
+ for style in added:
675
+ # The reference calls its body style `Normal`; a Chinese Word template
676
+ # calls the same style `a`. Point the links at the template's own ids.
677
+ for tag in ("w:basedOn", "w:next", "w:link"):
678
+ ref = style.find(qn(tag))
679
+ if ref is None or ref.get(qn("w:val")) in have_ids | added_ids:
680
+ continue
681
+ target = id_by_name.get(base_name_by_id.get(ref.get(qn("w:val")), ""))
682
+ if target:
683
+ ref.set(qn("w:val"), target)
684
+ else:
685
+ style.remove(ref)
686
+ if style.get(qn("w:styleId")) == "Compact":
687
+ # Table cells are `Compact`, based on the body text. A template's
688
+ # body text is often indented for prose — a hanging indent of
689
+ # 1.7 cm in one competition form — and every cell inherited it:
690
+ # a number wrapped onto a line that started past the cell's edge
691
+ # and printed "86." for 86.7.
692
+ ppr = style.find(qn("w:pPr"))
693
+ if ppr is None:
694
+ ppr = etree.SubElement(style, qn("w:pPr"))
695
+ for old in ppr.findall(qn("w:ind")):
696
+ ppr.remove(old)
697
+ ind = etree.SubElement(ppr, qn("w:ind"))
698
+ for side in ("w:left", "w:right", "w:firstLine"):
699
+ ind.set(qn(side), "0")
700
+ ours.append(style)
701
+
702
+ with zipfile.ZipFile(template) as source, zipfile.ZipFile(dest, "w", zipfile.ZIP_DEFLATED) as out:
703
+ for item in source.infolist():
704
+ data = source.read(item.filename)
705
+ if item.filename == "word/styles.xml":
706
+ data = etree.tostring(ours, xml_declaration=True, encoding="UTF-8", standalone=True)
707
+ out.writestr(item, data)
708
+ return dest
709
+
710
+
641
711
  def _pandoc_warnings(stderr: str) -> list[str]:
642
712
  """The first line of each pandoc warning, which is the actionable one.
643
713
 
@@ -682,7 +752,10 @@ def _render_via_pandoc(
682
752
 
683
753
  # Use reference doc for styling if available
684
754
  ref_doc = reference_doc if reference_doc is not None else _REFERENCE_DOC
755
+ merged_ref = Path(output_path).with_name(Path(output_path).stem + ".reference.docx")
685
756
  if ref_doc.exists():
757
+ if ref_doc != _REFERENCE_DOC:
758
+ ref_doc = _with_pandoc_styles(ref_doc, merged_ref)
686
759
  cmd.extend(["--reference-doc", str(ref_doc)])
687
760
 
688
761
  # Standalone output
@@ -722,6 +795,8 @@ def _render_via_pandoc(
722
795
  except Exception as exc:
723
796
  logger.error(f"[DOCX_RENDER] pandoc error: {exc}")
724
797
  return False
798
+ finally:
799
+ merged_ref.unlink(missing_ok=True)
725
800
 
726
801
 
727
802
  # ------------------------------------------------------------------
@@ -808,6 +883,48 @@ def _sect_break(width: int, height: int, margins: dict[str, int], landscape: boo
808
883
  )
809
884
 
810
885
 
886
+ _UNSIZED_SEPARATOR_RE = re.compile(r"^\s*\|(?:\s*:?-{3}:?\s*\|)+\s*$")
887
+ _CELL_SPLIT_RE = re.compile(r"(?<!\\)\|")
888
+
889
+
890
+ def _size_author_tables(md: str) -> str:
891
+ """Give an author's pipe table the column widths its content needs.
892
+
893
+ Tables built from source data are sized when they are placed; a table the
894
+ author wrote into a draft kept its " --- " separators, which pandoc prints
895
+ as equal columns: a column of ①②③ took a quarter of the page while the
896
+ sentences beside it wrapped every four characters. A separator someone
897
+ sized by hand (any column with more than three dashes) is left alone.
898
+ """
899
+ from .source_tables import _column_dashes
900
+
901
+ def cells(line: str) -> list[str]:
902
+ parts = _CELL_SPLIT_RE.split(line.strip())
903
+ return [part.strip() for part in parts[1:-1]]
904
+
905
+ lines = md.split("\n")
906
+ i = 0
907
+ while i + 1 < len(lines):
908
+ if not (lines[i].lstrip().startswith("|") and _UNSIZED_SEPARATOR_RE.match(lines[i + 1])):
909
+ i += 1
910
+ continue
911
+ j = i + 2
912
+ while j < len(lines) and lines[j].lstrip().startswith("|"):
913
+ j += 1
914
+ headers = cells(lines[i])
915
+ marks = cells(lines[i + 1])
916
+ rows = [cells(line) for line in lines[i + 2:j]]
917
+ if len(headers) == len(marks) >= 2:
918
+ plain = lambda text: text.replace("**", "").replace("`", "")
919
+ dashes = _column_dashes([plain(h) for h in headers], [[plain(c) for c in row] for row in rows])
920
+ lines[i + 1] = "|" + "|".join(
921
+ f" {mark[0] if mark.startswith(':') else ''}{'-' * width}{mark[-1] if mark.endswith(':') else ''} "
922
+ for mark, width in zip(marks, dashes)
923
+ ) + "|"
924
+ i = j
925
+ return "\n".join(lines)
926
+
927
+
811
928
  def _wrap_wide_tables(md: str, reference_doc: Path | None) -> tuple[str, int]:
812
929
  """Put every table of `_LANDSCAPE_MIN_COLS`+ columns in a landscape section.
813
930
 
@@ -1600,8 +1717,9 @@ def _style_tables_post_render(docx_path: str) -> None:
1600
1717
  #: A table this many body rows or shorter fits on one page and is kept whole.
1601
1718
  SHORT_TABLE_MAX_ROWS = 15
1602
1719
 
1603
- _TABLE_CAPTION_RE = re.compile(r"^\s*(?:表|Table)\s*\d+\s*[..::]", re.IGNORECASE)
1604
- _FIGURE_CAPTION_RE = re.compile(r"^\s*(?:圖|图|Figure)\s*\d+\s*[..::]", re.IGNORECASE)
1720
+ #: 「表 1 標題」: Chinese typesetting may end the number with an ideographic space.
1721
+ _TABLE_CAPTION_RE = re.compile(r"^\s*(?:表|Table)\s*\d+(?:\s*[..::]| )", re.IGNORECASE)
1722
+ _FIGURE_CAPTION_RE = re.compile(r"^\s*(?:圖|图|Figure)\s*\d+(?:\s*[..::]| )", re.IGNORECASE)
1605
1723
  _TABLE_ATTRIBUTION_RE = re.compile(r"^\s*(?:來源|来源|資料來源|Source)\s*[::]", re.IGNORECASE)
1606
1724
  _TABLE_NOTE_RE = re.compile(r"^\s*(?:註|注|Note|Notes)\s*[..::]", re.IGNORECASE)
1607
1725
 
@@ -1859,6 +1977,15 @@ def run_docx_render(state: ReportState) -> ReportState:
1859
1977
  md_content, resolved_figures, unresolved_figures = _replace_figure_placeholders(
1860
1978
  md_content, figure_manifest, table_start_number=placed_tables
1861
1979
  )
1980
+ # Tables the author typed into the draft still need "表 N 標題".
1981
+ native_tables = len(re.findall(r"^(?:表|Table)\s+\d+\.", md_content, re.MULTILINE))
1982
+ md_content, captioned_author_tables = caption_author_tables(
1983
+ md_content,
1984
+ start_number=max(placed_tables, native_tables),
1985
+ language=detect_document_language(md_content),
1986
+ )
1987
+ if captioned_author_tables:
1988
+ state.output["author_tables_captioned"] = captioned_author_tables
1862
1989
  if resolved_figures:
1863
1990
  state.output["figure_placeholders_resolved"] = resolved_figures
1864
1991
  if unresolved_figures:
@@ -1977,7 +2104,7 @@ def run_docx_render(state: ReportState) -> ReportState:
1977
2104
  pandoc_input_md = run_dir / "pandoc_input.md"
1978
2105
  pandoc_md, flipped = _wrap_wide_tables(
1979
2106
  _inject_toc(
1980
- md_content,
2107
+ _size_author_tables(md_content),
1981
2108
  has_front_matter,
1982
2109
  cover_title=cover_title,
1983
2110
  title_leads=title_leads,