4.9 KiB
phase, title, status, priority, effort, dependencies
| phase | title | status | priority | effort | dependencies | |
|---|---|---|---|---|---|---|
| 2 | Phase 2: Fetch the dump | completed | P1 | 2h |
|
Phase 2: Fetch the dump
Overview
Point the Makefile, the Docker dict stage, the pin test, the CI leak guard and the README's
raw commands at Wikimedia's rolling latest dump instead of kaikki's JSONL, keeping the
three URL copies in agreement and a failed download unable to pass as a success.
Requirements
- Functional:
DICT_URLishttps://dumps.wikimedia.org/viwiktionary/latest/viwiktionary-latest-pages-articles.xml.bz2;DICT_SRCisdata/viwiktionary-latest-pages-articles.xml.bz2.fetch-dictusescurl -fLR—-Rkeeps the server's modification time, which is the dump's generation time and becomessource_fetched_at— to a.partname renamed on success, as today. - Functional:
dictrunsbuild-dictionary --dump ../$(DICT_SRC). - Functional: the Dockerfile
dictstage mirrors the URL and the flag;FIXTURE_DICT=1is untouched.curlgains-Rthere too. - Functional:
web/tests/dictionary-source.test.jsasserts the Makefile and Dockerfile URLs agree, that the URL matches^https://dumps\.wikimedia\.org/viwiktionary/latest/viwiktionary-latest-pages-articles\.xml\.bz2$, that the builder'sdumpSourceURLconstant indump.gois the same string, and that README anddata/ATTRIBUTION.mdquote it. - Functional: the CI leak guard rejects any
\.bz2$or\.xml$inside the image; the comment says the dump, not the export..gitignorecoversdata/*.bz2,data/*.bz2.part,data/*.xml(for the phase-1 fallback) and drops the.jsonllines. - Functional: README's "Without make" block, Make targets table and Setup section describe
a ~61 MB monthly dump; the
fetch-dicthelp line says the same. - Non-functional: still no resume flag.
latestcan be repointed between two attempts.
Architecture
DICT_URL := https://dumps.wikimedia.org/viwiktionary/latest/viwiktionary-latest-pages-articles.xml.bz2
DICT_SRC := data/viwiktionary-latest-pages-articles.xml.bz2
fetch-dict:
@mkdir -p data
curl -fLR -o $(DICT_SRC).part $(DICT_URL) && mv $(DICT_SRC).part $(DICT_SRC)
dict: $(DICT_SRC)
cd server && go run ./cmd/build-dictionary --dump ../$(DICT_SRC) --out ../$(DICT_OUT)
Correctness rests on: curl -f plus the .part rename (HTTP errors, interrupted
downloads); the bzip2 decoder (a truncated stream errors at EOF); the XML decoder (a cut
mid-page); the 20,000-page check and the 30,000-word floor (content).
Related Code Files
- Modify:
Makefile— header comment,DICT_URL,DICT_SRC,help,fetch-dict,dict - Modify:
Dockerfile—dictstage comment,ARG DICT_URL,curl -fsSLR, file name,--dump - Modify:
web/tests/dictionary-source.test.js— URL pattern, builder file and constant name - Modify:
.github/workflows/ci.yml— leak guard pattern and comment; theimagejob's comment about "the real upstream release" still holds - Modify:
.gitignore - Modify:
README.md— Setup, Make targets, Without make, Architecture table's dictionary row wording if it names the export
Implementation Steps
- Update the Makefile; run
make fetch-dicton a cleandata/and check the file's mtime is the dump's, not now. - Mirror in the Dockerfile.
- Rewrite the pin test; run
npx vitest run tests/dictionary-source.test.js. Edit one URL copy alone and confirm it fails. - Update the CI leak guard,
.gitignore, README. make dict; thendocker build .anddocker build --build-arg FIXTURE_DICT=1 .; run the CI file checks against the real image and confirm no.bz2/.xmlinside.- Point
DICT_URLat a 404 once and confirmfetch-dictfails; feeddicta copy of the dump cut at 40 MB and confirm the build fails naming the cause.
Success Criteria
make fetch-dictdownloads ~61 MB with the server's mtime;make dictbuilds >30,000 words with meanings.web/tests/dictionary-source.test.jspasses and fails when any one copy is edited.- Both image variants build; the real one passes the CI file checks; nothing matching
\.bz2$|\.xml$inside. grep -rniI kaikki --exclude-dir=plans .finds nothing outsideplans/.- A 404 URL and a truncated file each fail the build readably.
Risk Assessment
latest/ mid-repoint. Wikimedia updates the latest symlinks file by file as a run
completes. Fetching during the run can return the previous month's file, which is correct,
or in principle a 404 for a moment. Signal: curl: (22). Response: retry; nothing to fix.
Dump size grows. Irrelevant to correctness; the README's "~61 MB" goes stale slowly. Signal: none. Response: update the number when it is off by a quarter.
The Docker build now decompresses bzip2 in Go inside alpine. Same code, same speed as
locally. If phase 1 chose the bzip2 -dc fallback, the stage needs apk add bzip2 and the
pipe; the leak guard's .xml clause is why an uncompressed intermediate is also checked.