Skip to content

Translation reconciliation proves raw-source counterparts - #847

Merged
zlareb1 merged 4 commits into
mainfrom
fix/i18n-counterpart-origin
Nov 18, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
fix/i18n-counterpart-origin

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Translation reconciliation can retain original completed units across source insertions when raw source origins prove every current counterpart. Changed units keep their original references and remain subject to correction, refusal and request-byte limits.

Why

Adjacent changed completed units can lack an unchanged boundary that proves where each current counterpart ends. Guessing from headings or accepting caller-supplied ranges could reuse the wrong reply or omit source text.

The optional SourceOrigins input supplies historical raw source, current raw source and locale. The proof reconstructs both exact prepared containers through the maintained language-bar, ordered link-target and generated-anchor transformations. It then requires every historical raw line to survive in order. Earliest and latest complete monotone embeddings must agree on each endpoint's neighbouring origins; insertions at unit or separator boundaries refuse. Every original whole unit and separator must cover the complete current container.

Scope and risk

  • The optional path accepts fully completed manifests only. Without raw origins, the existing adjacent-change refusal remains. Replacements, reordering, ambiguous endpoints, unsafe parser cuts, incomplete coverage and cuts inside preparation transformations refuse.
  • Changed request bytes, including routing-only changes, receive changed; original reply references and fault identifiers remain attached. Existing pair refusals, unknown-fault checks and whole-page restrictions still apply. Changed and faulty whole counterparts must fit the caller's effective request-byte bound; the proof cannot split them or raise that bound.
  • Callers still authenticate raw source history, path, locale, prepared request, replies and settlement history. A source-origin proof does not clear a refusal, replay an old-input assistant response, approve translated prose or admit a provider call. Corrections use current input.
  • The shared preparer exposes the same prose offsets, link routes and anchor insertions to preparation and proof construction. A regression there could affect normal translation preparation, so the existing preparer cases and full CI remain required.
  • The architecture contract describes this API. Its English source change can make existing translations stale; this change does not alter translated files or source stamps. There are no dependency, server, SDK, provider, model, budget or worker-activation changes.

Compatibility, rollout and rollback

  • Wire: none. The Python reconciliation API adds an optional argument; its default preserves existing refusal behaviour.
  • Operator steps: none. A consumer must authenticate its source evidence and bind the current plan and effective bound before using this argument. Translation assembly, invariants and semantic review remain separate requirements.
  • Rollback: revert this change to restore the prior reconciliation path. No migration, stored data or generated output remains behind.

Tests

  • The definition-growth check measures a valid comma-separated binding, asserts every definition is extracted and excludes one-time parser initialization. The focused case fails before the fix and passes afterward with the same input sizes and growth limit.

  • Mirror-failure serialization tests restore their marked request-work context. Three ordered failure variants followed by two event-capture cases reproduce two failures before isolation and all five pass afterward. The production required-tail guard remains unchanged.

  • 120 directly related checks pass: 93 existing reconciliation cases, 23 source-origin cases and four existing link/anchor preparation cases. The cases cover ambiguous origins, endpoint insertions, replacements, missing coverage, altered preparation, incomplete manifests, retained refusals and faults, and whole-counterpart byte limits.

  • Two recorded complete 12-unit source histories each produce nine reusable and three changed whole counterparts, retaining all original references and exact current-container coverage. Their largest whole input is 9,994 UTF-8 bytes: it fits the recorded 16,384-byte bound but must refuse under an 8,192-byte bound. These are pure source proofs, with no provider calls or translated-body semantic approval.

  • Ruff, Ruff format, prose and diff checks pass. Full suites were not run locally; mandatory GitHub CI must pass before merge.

Reproduce the focused checks:

python -m pytest tests/unit/test_i18n_source_origins.py tests/unit/test_i18n_reconcile.py tests/unit/test_i18n.py::test_links_point_at_translations_or_the_english_files tests/unit/test_i18n.py::test_html_links_badges_and_reference_definitions_are_rewritten tests/unit/test_i18n.py::test_links_inside_code_are_left_alone tests/unit/test_i18n.py::test_anchors_follow_github_slugs_across_sections -q -p no:randomly

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the diff. The implementation was checked against the complete raw-source correspondence contract, focused adversarial cases and both recorded source histories. Fresh review of the pushed head and mandatory CI remain pending.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files require no regeneration; this change adds no generated schema, SDK, reference table, reach manifest or plugin file.
  • No migrations change.
  • No plugin-shipped files change.
  • No frontend files change.
  • The architecture page describes the raw-origin contract; operator steps and wire changes are listed above.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off.

A changed counterpart can exceed the request bound without having a recorded fault.

Signed-off-by: zlareb1 <[email protected]>
Bind the marked work bag to the serialization check so later event tests cannot inherit it.

Signed-off-by: zlareb1 <[email protected]>
Use a valid comma-separated binding and verify every declarator is extracted. Keep the same growth bound while initializing the parser outside the measured calls.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 63db56e into main Nov 18, 2026
81 of 82 checks passed
zlareb1 added a commit that referenced this pull request Nov 18, 2026
Related: #847

### Changelog category (leave one):

- Improvement

### Changelog entry

Translation reconciliation accepts bounded changes to a completed whole page when authenticated raw source origins prove its complete current counterpart.

### Why

A completed whole page is refused before the optional source-origin proof runs. This blocks insertion-only source updates even when the proof establishes their exact original request and complete current boundary.

### Scope and risk

One condition lets supplied `SourceOrigins` reach the existing mandatory proof. Unproved replacements still refuse. Invalid raw source, ambiguous origins, changed separators, incomplete history, confirmed pair refusals and oversized whole requests retain their existing checks. A changed whole remains one request with its original identity and fault references.

The diff adds focused regressions and states the contract in the architecture guide. It changes no generated translation or paid execution policy.

### Compatibility, rollout and rollback

- Wire, settings and operator steps: none.
- Exact whole-page reuse and same-input correction retain their behavior. Changed inputs require their current source; this does not authorize replaying an old-input assistant response.
- Rollback restores the refusal for changed whole pages. No stored application data or existing translation bytes change.

### Tests

- The new named whole-page regression fails before the source fix at the existing replacement refusal.
- The final focused source-origin cases and adjacent whole-page, refusal and request-bound controls pass: 51 cases. They cover changed whole requests, faults, invalid or absent proof, unchanged reuse/correction and UTF8 bounds without splitting.
- Ruff, formatting, diff and prose checks pass. Full suites run in GitHub CI and must pass before merge; no heavy local suite ran.

### AI assistance in the code (leave one; writing this description with AI is fine):

- AI-generated: Codex wrote the condition, tests and contract text; the publisher reviewed the complete diff, proof path and focused evidence.

- [x] I can explain every line of this diff and how it interacts with the rest of Loom.

### Checklist

- [ ] Required GitHub CI passes on the current head.
- [x] No migration, schema, SDK, plugin or frontend changes.
- [x] The architecture guide describes the proof requirement.
- [x] Existing generated translations and paid execution policy retain their values.
- [x] Commits are signed off.

Signed-off-by: zlareb1 <[email protected]>
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
zlareb1 added a commit that referenced this pull request Nov 18, 2026
Related: #847
Related: #873

### Changelog category (leave one):

- Improvement

### Changelog entry

Translation reconciliation retains each completed reply's original source partition when planning corrections across source updates.

### Why

A later translation can reuse older replies while generating only a changed section. Treating those replies as one request history assigns some replies to a container that never produced them. A separate completed-history planner keeps each reply variant tied to its actual complete partition and whole request slot.

### Scope and risk

The pure planner requires the complete partition and reply catalog, explicit reuse eligibility for every reply, and a digest of that metadata. Selected reply references derive an ordered complete current cover without caller-supplied cuts. Each current separator must match the selected reply's own original partition separator. Same-input faults produce corrections; changed inputs retain their original identity and use current source. Eligible same-input alternatives require reuse. Completed wholes are never split to fit the byte bound.

The caller must authenticate catalog completeness, actual reply variants, source and settlement evidence, eligibility, uncertainty, partial attempts, refusals and security policy. A consistent metadata digest cannot establish those facts or admit provider calls. Unselected replies, faults and origin evidence remain in the result.

The existing single-history API retains its contract. A shared raw-origin calculation is factored behind its existing completed-unit guard. The architecture guide describes the separate completed-history contract.

### Compatibility, rollout and rollback

- Wire, settings and operator steps: none.
- Matching consumers must authenticate each selected reply against its own complete source partition. This PR changes no executor, generated translation or paid execution policy.
- Rollback removes the separate planner and restores the shared calculation in place. No stored application data changes.

### Tests

- A missing-feature regression fails before implementation because the new API is absent.
- `python -m pytest tests/unit/test_i18n_completed_history.py tests/unit/test_i18n_source_origins.py -q -p no:randomly -o addopts=`: 74 focused cases pass. They cover provenance, variant-specific faults, full-catalog eligibility, free alternatives, exact current coverage, raw-source proofs, refusal, separator ownership in both directions and UTF8 bounds.
- Ruff, formatting, diff and prose checks pass. Full suites run in GitHub CI and must pass before merge; no heavy local suite ran.

### AI assistance in the code (leave one; writing this description with AI is fine):

- AI-generated: Codex wrote the planner, tests and contract text; the publisher reviewed the complete diff, provenance boundaries and focused evidence.

- [x] I can explain every line of this diff and how it interacts with the rest of Loom.

### Checklist

- [ ] Required GitHub CI passes on the current head.
- [x] No migration, schema, SDK, plugin or frontend changes.
- [x] The architecture guide describes the new contract and caller obligations.
- [x] Existing generated translations and paid execution policy retain their values.
- [x] Commits are signed off.

Signed-off-by: zlareb1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant