fix: 8 code-review findings — front-matter guard, gate cwd fallback, dedup (v5.68.1)#50
Merged
Merged
Conversation
…ack (v5.68.1) Fixes 8 verified code-review findings: 1. fix_footnotes.py leading-tab indent functions now share the same seen_h1 front-matter guard as their siblings (normalize_body_indent, apply_template_body_styles) so title/abstract/TOC paragraphs are never touched. 2. mechanical-floor-gate.py / writing-mechanical-gate.py now fall back to hook_input["cwd"] when args.projectDir is absent (Agent tool calls never carry it), fixing FLOOR=dev auditing "." instead of the real project. 3. fix_leading_tab_indents now emits a WARNING change entry instead of silently no-oping when tab-led paragraphs exist but no real firstLine indent exists to infer the dominant value from. 4. Extracted hooks/_gate_common.py (deny + _project_from_args) shared by both gate hooks; each hook still runs standalone via sys.path-insert. 5. Extracted _dominant_firstline() and _ensure_ind() helpers, used by both normalize_body_indent and fix_leading_tab_indents. 6. Extracted _iter_unstyled_body_paras()/_iter_leading_tab_paras() generators shared by each pass's count and fix functions. 7. Skipped the 3-round-trip main() perf refactor (--restyle-body path) — not low-risk enough given the findings-5/6 refactor already landing in the same file. 8. build_docx.py's convert_to_pdf now prints a loud stderr WARNING when it falls back to the non-Word x2t/LibreOffice path, instead of silently contradicting the docx-render "--renderer word for deliverables" law. Tested: tests/test_mechanical_floor_gate.py (11/11) and tests/test_writing_mechanical_gate.py (8/8) pass; both hooks' CLI debug modes run cleanly; py_compile on all edited files; synthetic-XML smoke tests for the front-matter guard, WARNING path, and count/fix parity in fix_footnotes.py. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J3NEAUUosUHyci4iFZBH2J
This was referenced Jul 5, 2026
edwinhu
added a commit
that referenced
this pull request
Jul 5, 2026
edwinhu
added a commit
that referenced
this pull request
Jul 5, 2026
edwinhu
added a commit
that referenced
this pull request
Jul 5, 2026
This was referenced Jul 5, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes 8 verified code-review findings (3 correctness, 5 cleanup) surfaced against
skills/docx-repair/scripts/fix_footnotes.py,hooks/mechanical-floor-gate.py/hooks/writing-mechanical-gate.py, andskills/law-review-docx/scripts/build_docx.py._count_leading_tab_indents/fix_leading_tab_indentswere missing theseen_h1front-matter guard their siblings (normalize_body_indent,_count_unstyled_body_indents,apply_template_body_styles) all enforce. Added the guard to both (via a shared_iter_leading_tab_parasgenerator — see Your Strunk & White linter as a live editor -- paste a paragraph, get it back tighter #6). Updatedskills/docx-repair/SKILL.md(~line 364) to document the front-matter guard applies here too._project_from_argsonly readargs.projectDir, whichAgenttool calls never carry, soFLOOR=devalways audited"."(the hook process's own cwd) instead of the real project. Fixed by falling back tohook_input["cwd"](threaded through frommain()) before defaulting to".". Applied identically to thedsbranch and towriting-mechanical-gate.py's call site, via the shared helper in cite-check: materialize-sources writes stale .md file paths to sources.bib #4.fix_leading_tab_indentssilently returned[]when tab-led paragraphs existed but no paragraph anywhere had a realfirstLineindent to infer the dominant value from — contradictingdetect_issues(which still reportsleading_tab_indent(N)) and the SKILL.md "Logged, never silent" claim. Now returns aWARNING: N leading-tab paragraph(s) detected but no real firstLine indent exists to infer the dominant value — not fixedchange entry instead.hooks/_gate_common.py(deny,_project_from_args) shared by bothmechanical-floor-gate.pyandwriting-mechanical-gate.py, which duplicated them byte-for-byte. Each hook still runs standalone viauv run python3 <path>— imports the sibling module with asys.path.insert(0, str(HOOKS_DIR))since hooks run from an unknown cwd._run_dev/_run_ds/_run_check_all(dev/ds/writing-specific check-all invocations) were left in their respective hook files — the existing regression tests (tests/test_mechanical_floor_gate.py,tests/test_writing_mechanical_gate.py) assert on literal source-text of each hook's own file (e.g.'"--with", "lxml"' in src), so extracting those would have broken the tests without adding real dedup value (they already differ per-branch:CHECK_ALL_PYvsCHECK_ALL_DSvsCHECK_ALL)._dominant_firstline(paras)(the dominant-firstLineCounterloop) and_ensure_ind(pPr)(the schema-ordered<w:ind>create-and-insert block), previously duplicated betweennormalize_body_indentandfix_leading_tab_indents. Both functions now call the shared helpers; insertion-point behavior (beforerPr/sectPr, else appended) is preserved exactly._iter_unstyled_body_paras(root)and_iter_leading_tab_paras(root)generators, each shared by its count function and its fix function (mirroring_iter_bio_ref_runs). The front-matter guard fix from Add ETL pipeline incremental testing pattern to ds workflow #1 lives in these shared iterators, so both the detector and the fixer get it for free.build_docx.py'sconvert_to_pdfnow prints a loudWARNING: Word unavailable — PDF rendered via x2t/LibreOffice, layout may reflow; re-render with --renderer word before submissionto stderr when it takes the non-Word fallback path, instead of silently contradicting the docx-render Iron Law ("--renderer word for deliverables").doc_render.pyitself was not touched.Test plan
uv run python3 tests/test_mechanical_floor_gate.py— 11/11 passeduv run python3 tests/test_writing_mechanical_gate.py— 8/8 passedpython3 -m py_compileon every edited.pyfile (fix_footnotes.py, both hooks,_gate_common.py, build_docx.py)FLOOR=dev uv run python3 hooks/mechanical-floor-gate.py .anduv run python3 hooks/writing-mechanical-gate.py .— both run cleanly (no crash) in CLI debug modefix_footnotes.py(no fixture docx exists in-repo): front-matter guard preserves a leading-tab paragraph before Heading1 while fixing one after it; the "no real firstLine anywhere" case returns the WARNING and leaves the doc byte-identical;fix_leading_tab_indentsis idempotent (second run produces no changes);_count_unstyled_body_indents/apply_template_body_stylescount/apply parity holds after the shared-iterator refactorVersion
Bumped 5.68.0 → 5.68.1 in all 3 locations (
.claude-plugin/plugin.json,.claude-plugin/marketplace.jsonmetadata.version+plugins[0].version).🤖 Generated with Claude Code
https://claude.ai/code/session_01J3NEAUUosUHyci4iFZBH2J