Skip to content

docs: require i18n postprocess before skip#61960

Closed
hxy91819 wants to merge 2 commits into
mainfrom
fix-docs-i18n-postprocess-skip
Closed

docs: require i18n postprocess before skip#61960
hxy91819 wants to merge 2 commits into
mainfrom
fix-docs-i18n-postprocess-skip

Conversation

@hxy91819

@hxy91819 hxy91819 commented Apr 6, 2026

Copy link
Copy Markdown
Member

Summary

  • require docs-i18n postprocess completion before localized outputs become skippable
  • mark newly written localized docs as postprocess_version: pending and finalize them only after locale-link postprocess succeeds
  • add regression coverage for the sticky-failure path where stale English links could otherwise survive retries

Root cause

  • docs-i18n writes translated localized files before postprocessLocalizedDocs(...) runs
  • those files already carried a fresh x-i18n.source_hash, so a later postprocess failure could leave stale English-root links on disk
  • on retry with --overwrite=false, shouldSkipDoc(...) only looked at source_hash, so the broken file could be skipped indefinitely unless the English source changed

Fix

  • encodeFrontMatter(...) now writes x-i18n.postprocess_version: pending
  • postprocessLocalizedDocs(...) upgrades that marker to the current postprocess version only after it rewrites or finalizes the file
  • shouldSkipDoc(...) now requires both a matching source_hash and the current postprocess version before it skips a localized file

Test plan

  • go test ./... in scripts/docs-i18n

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Apr 6, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3cd0ed3237

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/docs-i18n/doc_mode.go
@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a correctness bug in the docs-i18n pipeline where a failed postprocessLocalizedDocs call could permanently strand translated files with stale English-root links. Previously, encodeFrontMatter wrote a finalized source_hash immediately on translation, so a subsequent postprocessLocalizedDocs failure left the output file in a state that shouldSkipDoc considered complete — meaning those broken files would be silently skipped on every retry until the English source changed.

The fix is minimal and well-targeted:

  • encodeFrontMatter now writes postprocess_version: pending instead of the real version, making newly translated files non-skippable by default.
  • shouldSkipDoc now requires both a matching source_hash and postprocess_version == locale-links-v1 before allowing a skip.
  • postprocessLocalizedDocs upgrades pendinglocale-links-v1 on success, including the edge case where body links are already correct but the marker still needs finalizing (covered by TestPostprocessLocalizedDocsFinalizesPostprocessVersionWithoutBodyRewrite).
  • Two new regression tests in main_test.go cover the end-to-end pipeline wiring and the sticky-failure path.

The logic in setPostprocessVersion correctly handles both the insert-at-end and mid-block insertion cases. The continue guard in postprocessLocalizedDocs will never prematurely skip a file carrying the pending marker since updatedFrontMatter != frontMatter whenever the version needs upgrading.

  • One minor style note in the new test: a dead outputPath assignment on line 94 is immediately overwritten by the processFileDoc return value.

Confidence Score: 4/5

Safe to merge — the fix is minimal, logically correct, and well-covered by new regression tests.

Score reflects a clean, targeted bug fix with thorough test coverage and no critical issues identified. One minor dead-assignment in test code prevents a perfect score.

No files require special attention beyond the minor style note in scripts/docs-i18n/main_test.go.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/docs-i18n/main_test.go
Line: 94-96

Comment:
**Dead variable assignment before immediate overwrite**

The `outputPath` declared on line 94 is never read — it is unconditionally overwritten two lines later by the `:=` on line 96. Both computations produce the same path (`filepath.Join(docsRoot, "zh-CN", "gateway", "index.md")`), so there is no behavioral impact, but the first declaration is dead code. Consider removing it and relying solely on the return value from `processFileDoc`:

```suggestion

	skip, outputPath, err := processFileDoc(context.Background(), fakeDocsTranslator{}, docsRoot, sourcePath, "en", "zh-CN", true)
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "docs: require i18n postprocess before sk..." | Re-trigger Greptile

Comment thread scripts/docs-i18n/main_test.go Outdated
@hxy91819
hxy91819 force-pushed the fix-docs-i18n-postprocess-skip branch from 139a0fa to 2c7d62a Compare April 7, 2026 05:09
@hxy91819
hxy91819 force-pushed the fix-docs-i18n-postprocess-skip branch from 2c7d62a to 169f7d5 Compare April 8, 2026 08:38
@hxy91819
hxy91819 marked this pull request as draft April 24, 2026 15:06
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jun 14, 2026
@clawsweeper

clawsweeper Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open for maintainer handling: this draft, MEMBER-authored, maintainer-labeled PR is superseded by #92668 and current main has the more complete output-state implementation, but protected item rules prevent automatic cleanup close.

Root-cause cluster
Relationship: superseded
Canonical: #92668
Summary: This PR and #92668 address the same docs-i18n postprocess-before-skip root cause; the latter is merged and is the canonical implementation on main.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this PR as superseded by #92668.

So I’m closing this here and keeping the remaining discussion on #92668.

Review details

Best possible solution:

Close this PR as superseded by #92668.

Do we have a high-confidence way to reproduce the issue?

Yes at source level. The branch returns false for matching-hash non-English legacy outputs without postprocess_version, while current main classifies that same state as docOutputNeedsPostprocess and has regression tests for it.

Is this the best way to solve the issue?

No. The merged replacement is the better fix because it makes output readiness explicit, preserves legacy localized outputs, and tests the postprocess-only and max-bound paths this branch lacks.

Security review:

Security review cleared: No concrete security or supply-chain concern found; the diff is limited to local docs-i18n Go script logic and tests with no dependency, workflow, lockfile, credential, or execution-source change.

AGENTS.md: found and applied where relevant.

What I checked:

  • linked superseding PR: fix(docs): finalize i18n postprocess before skip #92668 (fix(docs): finalize i18n postprocess before skip) is merged at 2026-06-13T13:17:03Z.
  • cluster evidence: the durable review links that PR in the work cluster or recommended risk path.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • hxy91819: Authored this PR, the merged replacement PR, and earlier docs-i18n locale-link work on the same files. (role: recent area contributor and superseding fix author; confidence: high; commits: 169f7d5475fe, eaeedbf1f96b, 9b0ea7c57937; files: scripts/docs-i18n/doc_mode.go, scripts/docs-i18n/main.go, scripts/docs-i18n/process.go)
  • steipete: Recent commit history shows adjacent docs-i18n source workflow, Codex-backed translation, and hardening work before and after this area changed. (role: adjacent docs-i18n contributor; confidence: medium; commits: 394519325799, 219afbc2ccb4, f2dc241e9db7; files: scripts/docs-i18n/main.go, scripts/docs-i18n/doc_mode.go, scripts/docs-i18n/process.go)
  • joshp123: Earlier commits created and hardened the docs-i18n doc-mode pipeline that the current postprocess skip logic builds on. (role: earlier docs-mode pipeline contributor; confidence: medium; commits: e70984745be3, 0e0e395b9ebb; files: scripts/docs-i18n/doc_mode.go, scripts/docs-i18n/process.go, scripts/docs-i18n/main.go)

Codex review notes: model internal, reasoning high; reviewed against 7bbd09047bd7; fix evidence: commit eaeedbf1f96b, main fix timestamp 2026-06-13T13:17:03Z.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 21, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jun 23, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 29, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks @hxy91819. Closing as superseded by your later #92668, which explicitly supersedes this branch and shipped in v2026.6.8.

Current main uses explicit needs-translation, needs-postprocess, and ready output states; preserves legacy matching-hash localized outputs without retranslating them; honors the --max mutation bound; and includes focused failure and finalization coverage. This older draft is conflicted and has no distinct remaining work.

@steipete steipete closed this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants