[NOTICKET] fix(knowledge_extraction): close the notation rules against real backend markup
Rifqi Hafizuddin+1: Claude Opus 5
01c76dd
Sofhia supplied the same 11 equations as MinerU transcribed them under four
backends -- 44 real strings, committed as a fixture. Running the shipped
normaliser over them reproduced her figures exactly: 11/11 for vlm/medium,
10/11 for hybrid/medium, 8/11 for pipeline, against hybrid/high as reference.
Her independent check and this code agree on both the counts and which
equations differ, which is the point of her having run it separately.
The remaining gaps were in the command inventory, and the inventory is now
evidence rather than guesswork.
\mathsf and \displaystyle occur in this corpus and were missing -- \mathsf sets
the whole of equation 7 under pipeline, including its multiplication sign, and
\displaystyle appears in equation 4. Both are handled now, and the wrapped-x
rule generalises across every presentational wrapper rather than being \mathrm
specific.
Equation 4 needed two more, and one of them was a decision Sofhia deliberately
left open. The array ALIGNMENT SPEC arrives…
[NOTICKET] docs(knowledge-parsing): record that Chunk.latex is now load-bearing
Until a998ea48 this field was carried but unread — a parser change touching it
would have broken nothing. Extraction's formula guard now validates
`formula_latex` against it, so that is no longer true, and the contract has to
say so before someone tidies it in good faith.
The failure mode is the dangerous kind and gets the emphasis: reflowing or
dropping this field does not error. The guard simply has less to check against,
and claims it can no longer verify are recorded as unverifiable rather than
caught. Fewer things fail and nothing looks wrong.
The two obligations run OPPOSITE to the rule for `text`, which is why they are
stated rather than left to inference. `text` must stay verbatim because the span
check searches it literally. `latex` must stay UNCLEANED because extraction
canonicalises before comparing — pre-cleaning removes information the
canonicaliser was built to absorb. Character-spacing, `\mathrm{}` wrappers and
`~` are all expected input, not damage.
Also draws the li…
[NOTICKET] fix(knowledge_extraction): rule.txt few-shots stop contaminating the gold set (X23)
Rifqi Hafizuddin+1: Claude Opus 5
7e8614f
Two of the four worked examples were lifted from the reference corpus, and they
contaminated the measurement in opposite directions.
Example 2 used "Waterfall Analysis dapat di-review melalui dua metode" and
taught that it is NOT a rule. The gold set records that exact sentence as
WATERFALL_TWO_METHODS. The prompt was instructing the model to fail one gold
rule by construction, so the branch could not score above 14/15.
Example 1 was the inverse and had gone unnoticed: its evidence is gold rule
PTY_PRODUCTION_SOURCE verbatim (joint survey / truck count). That is a free hit
inflating the score, not capping it.
Both are now synthetic, which is the reasoning examples 3 and 4 already carried
in the prompt itself. The closing note is generalised: all four are synthetic,
so neither an answer nor a NON-answer for a real document leaks in.
The gold set was deliberately NOT touched, following the X22 precedent -- the
prompt is tuned constantly and the gold is the measuring instrument, so th…
[NOTICKET] docs(knowledge-parsing): B1 — Colab, and the two decisions it forces
Pak Ricky prefers a Colab subscription over provisioning a GPU. That is
consistent with what §4 already argued — the invoice is decided by the billing
model, not the compute — so the structure holds and only the recommendation
moves. Colab is also not a migration: every backend figure in §3 was measured
there already.
Measured against the same corpus: Colab Pro is $9.99/month for 100 compute
units and a T4 burns ~1.19 CU/hour, so the allowance is ~84 T4-hours and the
entire 16-hour worst-case backfill costs ~19 CU — a fifth of one month, five
times over-covered. Effective $0.119/GPU-hour against Azure's $0.752. The
spread between best and worst provisioning widens from ~80x to ~290x.
Azure figures deliberately STAY. Every hour-to-dollar conversion in §3 and §5
derives from that rate, so removing it would strip the tables of their basis —
and it is the fallback if the governance question below lands the wrong way.
New §4.1 records the two decisions that are not ours, because the chea…
[NOTICKET] feat(knowledge_extraction): record which guarantee formula_latex carries
Rifqi Hafizuddin+1: Claude Opus 5
f81a227
Three paths leave formula_latex populated and they are not equally strong:
located in the source markup, no markup to check against, or an operator the
source cannot express. Until now the output could not tell them apart, so a
verified formula and an unverifiable one reached the expert as identical rows.
That gap is not theoretical. MinerU's pipeline backend writes multiplication as
a bare letter x, so every product formula from such an artifact is unverifiable
-- including the Production formula this contract uses as its own worked
example. Every artifact on Sofhia's machine is pipeline, because she has no GPU.
FormulaEntry gains latex_verification: verified | unverified_no_markup |
unverified_operator, null when there is no claim to characterise. Set by the
span check, never by the model -- the model cannot know which guard ran, and a
field it could write would be a claim rather than a record.
_mark_latex is a never-throw seam like the rest of validation: an entry type
without th…
[NOTICKET] fix(knowledge_extraction): compare formula_latex by notation, not identity
Rifqi Hafizuddin+1: Claude Opus 5
a998ea4
9c8a6e4 gave formula_latex the right haystack and the wrong test. Sofhia ran it
against real artifacts and found `Production = MOHH \times Qty \times ...`
rejected: the `pipeline` backend transcribes the multiplication sign as a bare
letter x, so the claim had nothing to match.
Probing further, the problem was wider than the case she hit. Against a source
that DOES carry \times, the guard also rejected a model that dropped \mathrm{},
one that used \cdot, and one that wrote idiomatic LaTeX -- 4 of 5 plausible
correct outputs. It passed only when the model mirrored MinerU's notation
character for character. The test that shipped green passed only because I
hand-wrote the fixture to mirror the source.
That is the same category error as the original defect, one level up. First the
haystack was the wrong FORMAT; then it was the wrong NOTION OF CORRECTNESS. The
prompt asks the model to transcribe INTO LaTeX, which is a translation, and
identity is not how you check a translation.
normalis…
[NOTICKET] docs(knowledge-parsing): B1 — cost justification for the BUMA corpus
Owed from the 13 Aug executive review. Every number was already measured; this
is the write-up, plus one finding that only surfaced while doing the arithmetic.
The finding: $0.752/hour is derived from a monthly VM price ($548.96 / 730 h).
So $6.89 for the full corpus is only true if the VM is billed per hour and
deallocated afterwards. Left running — the default unless someone says
otherwise — the same 9.2 hours of work bills $548.96/month. That is an ~80x
spread for identical work, and it is the only decision in the document that
moves real money, so it leads.
Parsing is an admin-triggered offline batch and the service never imports
MinerU at runtime, so there is no reason to hold a GPU idle between runs.
Also recorded:
- Size from the heaviest document, not the average. Density spread is 2.66x
(the 9-page standard is 8.51 s/page against the 20-page handbook's 3.20),
and the dense document is the shorter one. Planning range $4.55-$12.09;
budget the $12 end, since BUM…
[NOTICKET] fix(knowledge_extraction): formula_latex is checked against Chunk.latex
Rifqi Hafizuddin+1: Claude Opus 5
9c8a6e4
The field was guarded in name only. It sat in GUARDED_FIELDS but not in
_TRANSCRIBED, so its value was never searched in the source -- only its
provenance.span was. A structurally wrong transcription with a valid prose span
passed, which is exactly the shape X21 produced: a \frac that lost its division
reads as a product and states something the document does not.
Adding the field to _TRANSCRIBED was not the fix. `text` carries rendered prose
and can never contain LaTeX, so that would have nulled every formula entry and
presented as a model failure rather than a validation bug. The haystack was the
problem, not the check.
Chunk.latex is now the haystack. The parsing half has always emitted it;
extraction's adapter dropped it on the floor, which is what left the claim
unprovable. It now crosses the seam and is compared with whitespace removed
ENTIRELY rather than collapsed.
That is a different notion of equality, not a weaker one. In LaTeX, whitespace
outside \text{} is not significa…
[NOTICKET] docs(knowledge-parsing): settle determinism; finish the English pass
Determinism was the one thing left open on the backend decision: the VLM
family is not deterministic in general, so a frozen baseline might drift and
no eval number could be trusted.
It does not drift. Two runs over the same documents, with the parse cache
moved aside so both genuinely re-parsed (from_cache: false on all four
records), produced 0 differences across 50 chunks. All four image
descriptions were present in both runs and character-for-character identical
(192, 256, 77, 146 chars) — those are the only model-written content in the
artifact and were the likeliest to wobble.
Existing baselines therefore stay valid and need no re-measurement, and
hybrid/high is final rather than provisional. Marked settled in config.py,
calibration §13, and REPO_STATUS §14.
The parsing README was still Indonesian in the how-to-use sections written
last week, while the .py files had already moved to English; it is now
English throughout. Its console example was also stale — it showed the old
I…
Harry's review of the output contract asked for four things: an id on every
entity, a formula referenced rather than restated, rules related to formulas,
and a smaller schema. All four are adopted.
Two defects surfaced while adding the ids, and they matter more than the ids do.
Neither existing identifier survived a re-run: `cluster_id` was a frequency-rank
ordinal (`#c000` over a list sorted by mention count), so one changed count
reshuffled every id after it, and `rule_id` was written by the model, so the same
rule could return a different slug next run. The product is an expert working a
review queue — if Mas Beta approves 40 entries and a prompt is retuned, unstable
ids lose which 40. Approval continuity, not linking, is why these exist.
New `ids.py` mints term/formula/rule/brief ids as sha256 over content: never
positional, never model-supplied. New `link.py` resolves every reference after
the branches run — deterministic, no LLM, no spend — and returns dangle counts
rather than…
[NOTICKET] docs(knowledge-parsing): record the backend measurement, and fix three stale facts
The backend decision was in the code and in a commit message, but the evidence
behind it had no home in the repo. Anyone asking "why hybrid/high" would find
the conclusion and none of the data.
**Calibration §13 — all four backends measured.** One GPU, the same 29 pages.
`vlm` and `hybrid/high` produce IDENTICAL output (100% LaTeX overlap, same image
descriptions), so `vlm` only costs more time. `pipeline` is the only backend
copying the multiplication sign as a literal letter, which fuses MOHH/Qty/PA/UA/
Pty into one token — and it is slower than hybrid/medium, so it loses twice. The
choice narrows to medium vs high, i.e. whether image descriptions are wanted:
$2.67 against $6.89 across 6,800 pages.
Also records what the descriptions actually cost in coverage. MinerU only
describes a picture it first classified into a sub_type, and the pattern held 6
of 6: no sub_type, no description. Coverage was 4 of 6, and the miss is not
explained by image quality — a plainly legible waterfall c…
Syncs the two knowledge docs to what the branch actually holds after 296cdd7.
X20 goes to in-progress, not done. The prompt change is committed; the eval
CLAUDE.md 7B requires is not run, and the row says so rather than implying the
regression is fixed. It records what the three edits are, that worked example 3
is synthetic on purpose (MTTR, absent from all 15 gold rules) so no gold answer
leaks into the prompt, and that example 1 already is PTY_PRODUCTION_SOURCE
verbatim -- pre-existing contamination the new example deliberately did not add
to.
X22 goes to done. Rifqi fixed it in abae344 on 2026-08-24 by changing the
scorer, not the gold: underscores are deleted rather than spaced, because
spacing turns qty_a into "qty a" which still does not contain qtya. Marked
RESOLVED with the reasoning rather than deleted, per house convention.
That resolution moves X20's target. The 1/15 in
v2_full_document_2026-08-24_093051.json was measured with the pre-X22 scorer,
so the number any X20 re-…
[NOTICKET] refactor(knowledge-parsing): English throughout the module
The parsing half was written in Indonesian — identifiers, docstrings, comments,
manifest keys and console output. Everything else in the repo is English, and
this module is the newest work, so it is the one to bring into line rather than
the older code around it.
Renamed across the module: parse_dokumen -> parse_document, normalisasi ->
normalise, pulihkan_batas_kata -> restore_word_boundaries, kosakata_layak ->
trustworthy_vocabulary, periksa_items -> check_items, CatatanDokumen ->
DocumentRecord, and the locals with them.
Docstrings and comments were REWRITTEN rather than translated word for word.
Several carry the reasoning behind a decision — why `\frac` is unwrapped before
the braced wrappers, why a heading never enters `text`, why the digit threshold
is 3 — and a mechanical translation would have flattened exactly the part worth
keeping.
Manifest keys move too: detik_per_halaman -> seconds_per_page, peringatan ->
warnings, jenis -> kind, galat -> error. That is a data change, …
Records what the code change added: `image` joins ChunkKind, and
`generated_description` carries MinerU's model-written description of a picture.
Two things a consumer would otherwise get wrong. Backends disagree on the label
— a figure `pipeline` calls a chart, `vlm` calls an image — so branching on one
of them silently misses half the cases. And whether descriptions exist at all
depends on the backend: never on `pipeline`, disabled outright on `hybrid`
medium, on for `hybrid` high and always for `vlm`. An artifact carrying nulls
here is not a parsing failure, it is the backend, which is one more reason
`parser_backend` has to travel with the data.
Also states why the field is kept out of `text`: that field is what the
extraction guardrail searches to prove a quote is verbatim, and generated prose
there would let a hallucination pass the check built to catch it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
[NOTICKET] docs: reorganise into docs/ and give every doc a status banner
Rifqi Hafizuddin+1: Claude Opus 5
f1342ce
The root carried 14 markdown files and no way to tell which were authoritative.
That knowledge lived in CLAUDE.md §1 and in Rifqi's head, which works for us and
fails for anyone else — and one of the stale ones already has a named failure
mode ("The Stale-Doc Believer") for being implemented from.
Root now holds four: REPO_STATUS, DEV_PLAN, API_CONTRACT_BE_PYTHON, README.
Everything else moves under docs/, by git mv so history follows:
docs/knowledge/ context, TODO, calibration, parsing output contract
docs/plans/ SPINE_V2_PLAN (approved, W3 deferred), DS_TOOLS_PLAN (proposal)
docs/archive/ API_ENDPOINTS_RESTRUCTURE, CODE_REVIEW_2026-07-23, PROJECT_BRD
docs/reference/ API_CONTRACT_BE_GOLANG (the Go repo's, a copy that can drift)
Every doc gains a one-line status banner under its H1, marked <!-- doc-status -->:
LIVE / LIVE PLAN / PROPOSAL / ARCHIVED / REFERENCE. Archived ones name what
superseded them — API_ENDPOINTS_RESTRUCTURE now opens with "DO NOT IMPLEMENT FROM…