Repository navigation
Conversation
apply takes a memory, a set of upstream catalogs and a stamp, and produces the exact bytes of every file in the content repo. It calls no model and reads no clock, which is what makes --check possible: CI renders the same inputs and compares, so a hand edit on the content repo fails the build by name instead of being overwritten on the next run and mentioned in a log. Structure comes from upstream and translations come from the memory. Upstream owns which strings exist, in what order, with which source references; the memory owns what they say. Keeping those apart is what lets one memory serve several version branches, since the 85 192 strings 3.14 and 3.15 share are the same segments in a different arrangement. Precedence is enforced where it matters, at the moment of writing. An entry already in the target that is translated and not fuzzy is returned whole, with the physical lines it was read from, so a reviewed string produces zero diff bytes and no machine translation can land on top of it. The spec says apply refuses to run in that case. Refusing the entry is the same guarantee and a workable one: a reviewer unfuzzying a string is the normal case, and refusing the run would leave the pipeline failing until the memory caught up with the catalog. Everything written carries a fuzzy flag and one provenance line naming the model, prompt, glossary, batch and run. Every field comes from the segment and none from the applying run. A field that fell back to the current run would say something untrue and would make --check report the whole corpus as changed the day after it was written, which is a check that fails so reliably it stops being read. --check renders each file with the revision date that file already carries, for the same reason. An untranslated upstream entry keeps its own lines rather than being re-rendered, because render_field reproduces 86.31% of this corpus's wrapping and rewriting tens of thousands of untouched fields to say what they already said is a diff nobody can read. An upstream entry that is fuzzy is blanked instead: gettext is not confident the string still matches its source, sync will not take it as ground truth, and carrying it here would launder it into something that looks like our work. Writes are atomic and only touch the files that changed, so git status after a nine-hour run is a report of the run rather than a list of every file in the repo.
7 tasks done
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.
Third box of #11.
applyis the step that turns the memory into the content repo.What it does
Given a memory, a set of upstream catalogs and a stamp, it produces the exact bytes of every file. No model call, no clock read. That is what makes
--checkpossible: CI renders the same inputs and compares, so an edit made by hand on the content repo fails the build by name rather than being reverted by the next run and mentioned in a log.Structure comes from upstream and translations come from the memory. Upstream owns which strings exist, in what order, with which source references and extracted comments. The memory owns what they say in Vietnamese. Keeping those apart is what lets one memory serve several version branches, since the 85 192 strings 3.14 and 3.15 share are the same segments in a different arrangement.
Precedence
Enforced at the moment of writing, not by a check that runs afterwards. An entry already in the target that is translated and not fuzzy is a string a person signed off on, and it is returned whole, with the physical lines it was read from, so it produces zero diff bytes.
Spec 01 §3 says
applyrefuses to run rather than overwrite a person's work. Refusing the entry is the same guarantee and a workable one. A reviewer unfuzzying a string is the normal case, and refusing the whole run would leave the pipeline failing until the memory caught up with the catalog. What matters is that no machine string ever lands on top of a human one, and none does.Provenance
Everything written carries
#, fuzzyand one comment line:Five fields, all from the segment, none from the run doing the writing. They describe when and how the string was translated, not when it was last copied into a file. A field that fell back to the applying run would say something untrue and would report the whole corpus as changed the day after it was written.
--checkrenders each file with the revision date that file already carries, for the same reason. Both of those were bugs I had until I diffed rendered output against disk.A passthrough gets a shorter line naming what it is instead:
# pydocvi: passthrough=version_marker.Two decisions about untouched entries
An untranslated upstream entry is passed through with its own lines.
with_msgstrdropsraw, andrender_fieldreproduces 86.31% of this corpus's wrapping, so re-rendering tens of thousands of fields that nobody has translated would reflow them all to say exactly what they already said.An upstream entry that carries a fuzzy translation is blanked instead. Fuzzy means gettext is not confident the string still matches its source,
syncalready refuses to take one into the memory as ground truth, and carrying it into this repo would launder it into something that looks like our work.Writing
Atomic, and only the files that changed. Leaving 548 mtimes alone is what makes
git statusafter a nine-hour run a report of the run rather than a list of every file in the repo.CLI
--checkexits 1 and names the files that differ.--dry-runprints the counts and writes nothing.Known consequence
X-Generatoris part of the headerapplyowns, so bumping the tool version makes--checkreport every file as changed until a re-apply. That is correct, since the generator did change, but it means a release lands with a re-apply in the same PR.Tests
33 new: 26 in
tests/test_apply.pycovering precedence, what upstream owns, the header, planning and writing, and--check; 7 intests/test_cli.pyfor the four endings of the command plus the usage error.apply.pyis at 100% line and branch coverage. Suite is 945 passing, 98.55% overall.