Repository navigation
Remove failed-new-file TOC entries before opening sync PR - #289
Conversation
|
@mmcky Please review the files under |
…notice (QuantEcon#156) Review follow-up on the failed-new-file TOC filter: - removeTocFileEntries no longer round-trips the TOC through yaml.dump. QuantEcon TOCs use the zero-indent block style js-yaml re-indents, so a one-entry removal became a whole-file rewrite (401 changed lines on the 204-line lecture-python TOC). Entries are now spliced out of the original text — the `- file:` line plus any deeper-indented `title:`/`sections:` children — and the result is verified by parse against the filtered document before a noArrayIndent re-serialisation fallback is considered. Real-TOC check: exactly the removed lines differ, nothing else. - Recursion covers `sections:` as well as `chapters:` at any depth. - A new markdown file whose *source* fetch fails never reached the filter (it is in fetchErrors, not filesToSync). fetchAllFileContents now probes the target on that path — 404 means nothing will be delivered under the name, any other answer keeps the entry — and passes the list into processFiles so those entries leave the TOC too. - The PR-body notice says what actually happened: names the TOC(s) the entries were removed from, or states that no TOC was in the changeset and a pre-existing target entry may still dangle. The unconditional "failure issue has been filed" is reworded; result.filteredTocPaths carries the distinction. - js-yaml import moved beside the other local imports so the bundle diff is the change itself (+207/-9) rather than an esbuild module reshuffle. - Tests: byte-identity on a QuantEcon-style fixture with comments, quoting and trailing whitespace; title/sections removal; nested sections; url/glob siblings; the fallback path; unparseable input; fetch-failed inputs; no-TOC-in-changeset; both PR-body wordings. Duplicate empty-set test removed. CHANGELOG and FAQ entries added. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks @kp992 — the mechanism here is right and this closes the #156 field case: the new-vs-existing distinction is derived correctly ( What the review found
Confirmed correct and left as-is: the stem mapping for flat, parts and subdirectory TOC layouts; the What changed in
|
…only target fetch (QuantEcon#254) Review follow-up on the _toc.yml caption preservation: - Matching by identical file set lost the caption of exactly the part a lecture-adding sync touches (measured on the real python/zh-cn pair: append one lecture to the first part and 基础工具 reverted to English). Parts are now paired by largest shared membership, each target part used once, ties to the nearest position. A part with no shared files keeps the source caption and is named in a warning; a matched part whose caption is already byte-identical to the source is logged as not localised. No positional guessing. - The merge no longer round-trips through yaml.dump (201 of 204 lines changed on lecture-python's TOC, comments dropped, re-dumped even when nothing was preserved). Caption values are substituted into the source text and the result is verified by parse against the intended document; noArrayIndent re-serialisation is the fallback only. - The rebase replay's `type: 'toc'` site in index.ts now fetches targetContent too, so a rebase no longer re-copies English captions. - Both target-TOC fetches swallow only a 404; any other status fails the fetch instead of silently dropping the captions on a transient error. - Code moved to src/toc-captions.ts (new module, new test file) so this PR and QuantEcon#289 — which inserts at the same point in sync-orchestrator.ts and adds the same js-yaml import — merge cleanly in either order. - Tests: byte-identity on a QuantEcon-style fixture with a comment, quoted caption and trailing whitespace; gain/lose/reorder a lecture; parts moved; new part; no-overlap part not guessed; split part; target-only parts; never-localised no-op by reference; no parts; malformed target; quoting; commented-out caption line; the block-scalar fallback; matcher unit tests. Orchestrator test asserts bytes. CHANGELOG, FAQ and architecture map updated. Merged current main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolve conflicts: keep [Unreleased] fix for QuantEcon#156 in CHANGELOG.md alongside new v0.28.1 and v0.29.0 release entries from main; rebuild dist-action bundle to regenerate sourcemap.
refreshed, draft #314 noted Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* chore: release v0.29.1 Patch: the Malayalam editor's round-3 answers (#315) — ml rules 27 → 28, glossary v0.7.0; corrects the -ഉം comma rule v0.29.0 shipped. No source change in this commit; dist-action/ rebuilds byte-identical. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * dev: STATE.md verified 2026-09-21 — downstream workflow PRs merged, #289 refreshed, draft #314 noted Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* preserve localised _toc.yml part captions on sync (#254) * fix prettier formatting in sync-orchestrator.ts * Overlap-matched, byte-preserving TOC caption merge; rebase path; 404-only target fetch (#254) Review follow-up on the _toc.yml caption preservation: - Matching by identical file set lost the caption of exactly the part a lecture-adding sync touches (measured on the real python/zh-cn pair: append one lecture to the first part and 基础工具 reverted to English). Parts are now paired by largest shared membership, each target part used once, ties to the nearest position. A part with no shared files keeps the source caption and is named in a warning; a matched part whose caption is already byte-identical to the source is logged as not localised. No positional guessing. - The merge no longer round-trips through yaml.dump (201 of 204 lines changed on lecture-python's TOC, comments dropped, re-dumped even when nothing was preserved). Caption values are substituted into the source text and the result is verified by parse against the intended document; noArrayIndent re-serialisation is the fallback only. - The rebase replay's `type: 'toc'` site in index.ts now fetches targetContent too, so a rebase no longer re-copies English captions. - Both target-TOC fetches swallow only a 404; any other status fails the fetch instead of silently dropping the captions on a transient error. - Code moved to src/toc-captions.ts (new module, new test file) so this PR and #289 — which inserts at the same point in sync-orchestrator.ts and adds the same js-yaml import — merge cleanly in either order. - Tests: byte-identity on a QuantEcon-style fixture with a comment, quoted caption and trailing whitespace; gain/lose/reorder a lecture; parts moved; new part; no-overlap part not guessed; split part; target-only parts; never-localised no-op by reference; no parts; malformed target; quoting; commented-out caption line; the block-scalar fallback; matcher unit tests. Orchestrator test asserts bytes. CHANGELOG, FAQ and architecture map updated. Merged current main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: record the #254 fix as unreleased The CHANGELOG entry sat under the released [0.28.0] section, and the FAQ said captions were mirrored "until v0.28.0". The fix is not in any release yet: the entry moves to [Unreleased], and the FAQ now says "in v0.29.3 and earlier", which stays true whatever the next version is. From Copilot's review of #291. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Matt McKay <mmcky@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Matt McKay <mamckay@gmail.com>
…om main; rebuilt in the next commit)
…QuantEcon#291 interaction - The CHANGELOG entry sat under [0.29.1] [YANKED], and git merged it there without a conflict. It now sits in the [Unreleased] section next to the QuantEcon#254 entry: one added line against main, none removed. - FAQ: the two _toc.yml answers each said the rest of the TOC is byte-identical, measured from different baselines. Each now names the other change. - New orchestrator test: a lecture-adding sync whose new lecture fails, against a localised target TOC. The caption merge runs first and the entry filter second, and together they hand back the target TOC unchanged. - dist-action/index.js.map rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @kp992. #291 merged first, so I brought this branch up to date and pushed two commits on top (
Checks on |
There was a problem hiding this comment.
🔵 Needs a closer look
It modifies the production sync pipeline's committed _toc.yml output with subtle text-splicing logic whose byte-preservation depends on YAML layout assumptions, warranting a human's final sign-off despite strong test coverage.
0 open findings
What changed in this PR
This PR fixes issue #156: when a sync run fails to deliver a new lecture (translation refused by the structural-parity guard, or source content that could not be fetched), the run previously still committed the source _toc.yml entry for that file, producing a dangling toctree reference that broke the target build under -n -W and corrupted cross-references in every sibling lecture that cited the missing file. The change reconciles the partial state after the per-file loop: it removes the undelivered new files' entries from any _toc.yml in the changeset (byte-preservingly) and surfaces the partial state on the PR body so reviewers understand why the PR is intentionally incomplete.
Changes:
sync-orchestrator.ts: adds exportedremoveTocFileEntries/collectTocFileshelpers plus a post-loopfilterTocForFailedNewFilesstep that drops TOC entries for new files that errored in the loop or failed to fetch, using a parse-verified line splice with anoArrayIndentre-serialization fallback.index.ts: threadsfetchFailedNewFilesout offetchAllFileContents(classified via a newtargetFileIsMissing404 probe) intoprocessFiles, and passes the resulting notice into PR creation.pr-creator.ts: adds aFailedNewFilesNoticeand a "Files Failed to Translate" PR-body section stating exactly what happened to the TOC entries.
| File | Description |
|---|---|
src/sync-orchestrator.ts |
Core TOC-filtering logic and new result fields (failedNewFiles, filteredTocPaths). |
src/pr-creator.ts |
New FailedNewFilesNotice type and PR-body notice threaded through createTranslationPR/buildPrBody. |
src/index.ts |
Returns fetchFailedNewFiles, adds targetFileIsMissing 404 probe, threads the notice into PR creation. |
src/__tests__/sync-orchestrator.test.ts |
Unit tests for removeTocFileEntries/collectTocFiles and orchestrator TOC filtering (flat/parts/nested, fetch-failed, caption-merge). |
src/__tests__/pr-creator.test.ts |
Tests for the "Files Failed to Translate" PR-body section (TOC vs no-TOC wording). |
docs/user/faq.md |
New FAQ entry explaining the notice and an update to the caption FAQ. |
dist-action/index.js |
Rebuilt action bundle matching the source changes. |
CHANGELOG.md |
[Unreleased] > Fixed entry documenting the #156 fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
* chore: release v0.29.4 Patch: #291 carries the target's translated _toc.yml part captions forward on sync and on the rebase replay (the #254 interim), #289 removes a failed new lecture's entry from the sync PR's _toc.yml (#156), and #335 is the ml rule-19 completive. No source change in this commit; dist-action/ rebuilds byte-identical. STATE.md brought up to date with the two merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * dev: STATE.md — date the new resume item instead of the heading The resume checklist's heading stays "2026-09-23, after v0.29.3", since only item 1 is new; the item now carries its own date (2026-10-09), as later additions on the page do. The verified: stamp is unchanged: this PR did not re-verify every bullet. Item 1 re-wrapped to the file's width. From Copilot's review of #354. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
When a sync run fails to translate a new lecture, the
_toc.ymlwas committed with an entry for the absent file, producing a dangling reference that broke the target build and corrupted cross-references in every sibling lecture.Changes:
sync-orchestrator.ts(filtering logic + exportedremoveTocFileEntries),pr-creator.ts(PR body notice),index.ts(thread new field through). New unit tests cover flat/parts TOC layouts, the existing-file exemption, and the PR body section.Fixes #156