← Back to Pull requests

feat(typeset): today's typesetting as layFlow and layPage, proven by replay (rebuild stage 2) #606

Open
unknown opened this pull request with 389 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 06, 2026 19:24 UTC
Author

Summary

Stage 2 of the rebuild, the typesetter: packages/typeset, today's typesetting ported rule by rule and proven by replay against a tap of today's reader, composed as two pure functions; and the first step of making it run on the prepare's parts instead of on facts the reader re-derives.

layPage(part, rows, rules, metrics) -> Page | wait
  layFlow        per flow, in a fixed order of rules; a flow that throws leaves its units the original's
  rules.ts       the registry: 56 rules, each with one home
                   47 ported (41 TypeScript, 6 today's JavaScript moved with types beside them)
                    9 facts that are the prepare's to state
  trace          writes the tap's slots, so a run is compared with today's ledgers
rulesFor(target) one data file per language

packages/typeset/        # the rules, the breaker and the fit, layFlow, layPage, the adapter from a Part
packages/engine/src/locate/   # facts stated as today's reader defines them (line size, baseline, measure)
lab/typeset/             # the replays, the two runners, the served-font measurer

Evidence

  • Each rule against today's recorded output (every field compared): the fit's walk on 32,588 of 32,589 corpus rounds; the table rules on every call; S.figures 14,351 of 14,351; D.text 308,051 segments; D.sentences 1,914,671 tokens; rulesFor equal to today's on all targets. The one round that differs lacks an input the tap does not record.

  • Whole papers on today's inputs (lab/typeset/gate.mjs, 123 reader dumps): 32,035 units, lost 0, gained 0, changed 12 (all from that one input).

  • Whole papers on the prepare's parts (gate-l1.mjs): 6,499 alike, lost 1,421, gained 414, changed 24,115. Not a fault of the port: a page shares one size and lead, so one unit whose facts differ changes its page (14,176 units change only through their page), and the reading and the tokens still come from the tap. The classes left are listed with counts and causes; closing them is the next pull request.

  • The measurer: the reader's served fonts through Skia; 98,848 of 98,862 recorded widths equal within 1/1000 px at 100 px; no measure missing.

  • The prepare's gate still holds after the fact changes: the differential exits 0, PDF.js proofs fail 0 pages, two runs byte-identical.

  • Gates: pnpm typecheck, pnpm lint, pnpm test (9,041 tests), pnpm build: all pass.
  • Merge Danger

    Door: two-way

    Blast Radius: none

    The base is the rebuild branch and no host calls layPage yet. One line of today's engine changes (pipeline/instrument.mjs passes \lineskip from the mark probe into the instrument).

    🤖 Generated with Claude Code

    <!-- devin-review-badge-begin -->

    ---

    <a href="https://app.devin.ai/review/srjoeee/readarxiv/pull/606" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4" alt="Devin Review"></picture></a>
    <!-- devin-review-badge-end -->

    Diff: 389 lines (+291 / -98) across 4 files Reviewer: devin-ai-integration[bot] Review duration: 22m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 389 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.357
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #606"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.1% (MEDIUM) · Higher = larger blast radius
    43.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.0% · Safe to merge
    23.0%