Skip to content

fix(i18n): stop parallel native PRs from conflicting in the string inventory - #163330

Merged
steipete merged 3 commits into
mainfrom
steipete/native-i18n-inventory-v3
Oct 2, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/native-i18n-inventory-v3

Conversation

@steipete

@steipete steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: native app PRs that land in parallel conflict in the generated string inventory apps/.i18n/native-source.json, even when they touch different source files.

On 2026-10-01 four native macOS sidebar PRs landed in parallel. #163165, #163164 and #163193 each hit a real conflict in that file after the previous one landed, which forced a rebase plus a full CI rerun of 25–34 minutes each. #163164 needed two extra runs.

User Impact

No user-visible change. Native developers can land independent PRs that add or reuse strings without inventory conflicts. CI still requires the committed inventory to equal a fresh pnpm native:i18n:baseline.

One-time cost: open PRs that already changed the v2 inventory will conflict once after this lands. To resolve, take either side and rerun pnpm native:i18n:baseline, which now overwrites any older or conflicted file instead of refusing to read it.

Why This Change Was Made

The v2 inventory stored one line per string, with every extraction site inline, sorted alphabetically. That line depends on every file that uses the string, so two PRs reusing "Retry" both rewrote it. Alphabetical order also put a feature's new strings ("Group by", "Group chat") into the same insertion gap. Replaying the sidebar PRs showed exactly these shapes, plus both PRs adding the same new string ("Project") with different sites.

Inventory v3 writes one line per extraction site, clustered by source file. The clusters are ordered by sha256(path), so new sibling files in the same directory don't share a gap. Each row's position depends only on its own content. Git, including GitHub's server-side merge-ort, therefore merges independent edits cleanly, and the merged text is byte-identical to a fresh baseline. The new scripts/native-i18n-inventory.ts owns serialization and parsing. The generator, the Android/Gradle reader and the Apple reader all move to it in this PR. The parser returns the same entries, in the same order, as v2 did, so Android and Apple projections are unchanged by construction.

Options considered:

  • Custom merge driver in .gitattributes. A custom driver needs merge.<name>.driver in Git config, which GitHub's server-side merge does not run, so PRs would still show as conflicting. It would only help local rebases. The built-in merge=union driver on the v2 layout produced output that differs from a fresh baseline in all three conflicting sidebar pairs: lines out of order, and a duplicate "Project" id. That turns conflicts into verify failures.
  • Dropping per-site data. Not possible. Android routes wear and third-party strings by site path and skips resource-string-only entries. Apple selects iOS vs macOS catalog entries by site path prefix and kind, and maps InfoPlist ids through plist-string sites.
  • One inventory file per source file. Replay: 13 conflicting pairs instead of 21 (essentially only same-file edits), in exchange for about 900 inventory files and directory-tree readers in Gradle, the workflow and CI routing. Not worth it.

Evidence

Scripted two-branch merge with the real generator. Each branch adds a new macOS view that reuses "Retry", adds an alphabetically adjacent new label, and adds the same new shared label. Each branch runs baseline --write and commits. Then git merge-tree --write-tree (GitHub's merge-ort) and a real git merge:

merge-tree git merge
main (v2) CONFLICT 2 hunks: adjacent labels plus the shared label; the "Retry" line
this PR (v3) clean clean; merged inventory == fresh baseline, no regeneration needed

History replay through the shipped serializer. Every commit's inventory delta is re-applied to the prior commit's parent, then merged with git merge-file --diff-algorithm=histogram:

Pairs v2 conflicting v3 conflicting
2026-10-01 sidebar PRs (#163162, #163165, #163164, #163193), all 6 pairs 3 0
All 162 inventory commits since 2026-09-01, each vs the next 4 (638 pairs) 64 21

14 of the 21 remaining v3 conflicts are pairs where both commits changed strings in the same source file. The other 7 are new or edited files landing in the same hash gap. The replay also reported 4 clean merges that differed from the expected result; these are dependent commit pairs where the later commit removed a row the earlier one added, not independent PRs.

Checks:

  • node --import ./scripts/tsx.mjs scripts/native-app-i18n.ts verify: pass.

  • Parsing the v3 file gives 4,443 entries that are deep-equal to the v2 entries, in the same order. serialize(parse(file)) round-trips byte-for-byte. Plain node loads the module, which is how Gradle runs android-app-i18n.ts.

  • native:i18n:check fails identically on main and on this branch: 1,554 missing translations (74 strings × 21 locales) from the sidebar PRs, waiting for the locale refresh workflow. CI runs this strict check only when generated artifacts change; this PR changes none.

  • Each touched test file passed with node scripts/run-vitest.mjs run <file> --maxWorkers=1:

    File Tests Wall time
    test/scripts/native-app-i18n.test.ts 46 4.9 s
    test/scripts/android-app-i18n.test.ts 36 3.9 s
    test/scripts/apple-app-i18n.test.ts 18 28.9 s (no new tests, under host load)
    test/scripts/ci-workflow-native-generated.test.ts 24 6.8 s
    src/scripts/ci-changed-scope.native-i18n.test.ts 7 2.5 s
  • The new merge regression test fails against a temporary v2 serializer, with the Group by/Group chat, Project and Retry conflict, and passes on v3. It spawns one git merge-file, no timers.

  • oxfmt, scoped oxlint, check-script-erasability and check-coercion-helpers: pass.

  • node scripts/check-changed.mjs --base origin/main on Blacksmith Testbox tbx_01m3xm1hsg7sk3k52eh952wmvk (Actions run): exit 0 in 34m45s. Every lane passed: typecheck (core tests, scripts, test root), lint (core, scripts, test root, Android ktlint), ratchets, format, dead-export scan and plugin boundaries.

  • Codex autoreview: scoped-clean, no findings.

Measured cost: inventory size 1,047,724 → 1,094,389 bytes (+4.5%), 4,448 → 5,632 lines. baseline --write takes 1.7 s and verify 2.3–3.1 s, unchanged.

Release-note context: internal native i18n tooling. No user-visible behavior change and no changelog entry.

…ventory

The generated native inventory stored one line per string with every
extraction site inline, sorted alphabetically. Two PRs reusing a string
("Retry") both rewrote its line, and a feature's new strings ("Group by",
"Group chat") landed in the same insertion gap, so parallel native PRs
conflicted in apps/.i18n/native-source.json and needed a rebase plus a
full CI rerun.

Inventory v3 writes one line per extraction site, clustered by source
file, with clusters ordered by a hash of the path so new sibling files do
not share a gap. Each row's position depends only on its own content, so
independent edits merge cleanly (including GitHub's server-side merge)
and the merged text equals a fresh baseline. The new
scripts/native-i18n-inventory.ts owns serialization and parsing; the
generator, Android/Gradle and Apple readers migrate to it together and
receive the same entries in the same order as before.
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added app: android App: android scripts Repository scripts size: XL labels Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 11:39 AM ET / 15:39 UTC (Revision 3).

ClawSweeper review

What this changes

The PR stores native translation strings by extraction site and updates Android, Apple, build inputs, and CI routing to reduce conflicts between independent native changes.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main still uses the conflict-prone v2 inventory. The coordinated reader cutover preserves existing inventory contents, and the supplied real-generator merge evidence supports the improvement. No actionable correctness or security findings remain.

Priority: P2
Reviewed head: 2db1975aa72a409e338e3bf0b14865cb39d310b9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, coordinated repair with strong merge evidence and verified inventory compatibility.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured real baseline-generator and Git merge replay exercises the changed inventory owner and observes clean after-fix merges equal to fresh generation. Existing-format compatibility is independently supported by exact reconstruction of all committed entries; related UI screenshots are not relied upon.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured real baseline-generator and Git merge replay exercises the changed inventory owner and observes clean after-fix merges equal to fresh generation. Existing-format compatibility is independently supported by exact reconstruction of all committed entries; related UI screenshots are not relied upon.
Evidence reviewed 8 items Pinned introduced change: Reviewed the introduced production, workflow, build, and test hunks from the pinned base to the original PR head. The new module owns serialization and parsing; both platform readers consume it.
Existing inventory compatibility: Read-only JSON inspection reconstructed all 4,443 base entries from the 5,628 committed v3 site rows. Entries and site ordering were identical to v2, with zero inconsistent rows. A separate comparison verified identical site-row contents and canonical hash ordering.
Current main still needs the change: The inventory at fetched main starts with version 2 and an entries array. The new inventory module is absent at that revision. The latest supplied release also retains version 2.
Findings None None.
Security None None.

How this fits together

Native localization tooling extracts strings from app source into a committed inventory. Android and Apple readers combine that inventory with translations to produce platform resources, while CI checks inventory consistency.

flowchart TD
  A[Native app source] --> B[String extraction]
  B --> C[Site-based inventory]
  C --> D[Git merge and CI verification]
  C --> E[Platform localization readers]
  F[Existing translations] --> E
  E --> G[Android and Apple resources]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +84, Config +2, Other +1252. Total +1338 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 5 168 84 +84
Docs 0 0 0 0
Config 1 2 0 +2
Generated 0 0 0 0
Other 7 5784 4532 +1252
Total 13 5954 4616 +1338

Review metrics

Metric Value Why it matters
Inventory compatibility 4,443 entries preserved exactly The format change preserves translation identities and extraction sites consumed by both platforms.
Code growth excluding generated inventory production/tooling +146/-87; tests/support +168/-84 Production growth establishes the shared format owner; regression coverage checks actual Git merge behavior.

Stored data model

Persistent data-model change detected: serialized state: scripts/android-app-i18n.ts, serialized state: scripts/native-app-i18n.ts, unknown-data-model-change: scripts/android-app-i18n.ts, unknown-data-model-change: scripts/native-app-i18n.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Use one site-based inventory owner while preserving stable translation IDs, platform projections, and baseline regeneration.

Do we have a high-confidence way to reproduce the issue?

Yes: the supplied real-generator two-branch replay establishes the v2 conflict and clean v3 result, and the inspected regression captures that trigger. This reviewer did not execute target code.

Is this the best way to solve the issue?

Yes: the shared format owner preserves existing entries and migrates every discovered reader together, avoiding a GitHub-incompatible custom merge driver or hundreds of inventory files.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 93e27de58fb2.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses recurring native development conflicts and expensive CI repetition without changing app behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured real baseline-generator and Git merge replay exercises the changed inventory owner and observes clean after-fix merges equal to fresh generation. Existing-format compatibility is independently supported by exact reconstruction of all committed entries; related UI screenshots are not relied upon.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured real baseline-generator and Git merge replay exercises the changed inventory owner and observes clean after-fix merges equal to fresh generation. Existing-format compatibility is independently supported by exact reconstruction of all committed entries; related UI screenshots are not relied upon.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the introduced production, workflow, build, and test hunks from the pinned base to the original PR head. The new module owns serialization and parsing; both platform readers consume it. (scripts/native-i18n-inventory.ts:13, 2db1975aa72a)
  • Existing inventory compatibility: Read-only JSON inspection reconstructed all 4,443 base entries from the 5,628 committed v3 site rows. Entries and site ordering were identical to v2, with zero inconsistent rows. A separate comparison verified identical site-row contents and canonical hash ordering. (apps/.i18n/native-source.json:2, 2db1975aa72a)
  • Current main still needs the change: The inventory at fetched main starts with version 2 and an entries array. The new inventory module is absent at that revision. The latest supplied release also retains version 2. (apps/.i18n/native-source.json:2, 93e27de58fb2)
  • Real merge proof: The captured PR body records two branches using the real baseline generator, shared Retry and Project strings, and adjacent new labels. Both merge-tree and git merge conflict on v2 and merge cleanly on v3; the merged v3 inventory equals a fresh baseline. Historical replay reports 64 versus 21 conflicts across 638 pairs and explicitly documents remaining same-file/hash-gap conflicts. Inspected prepared screenshots belong to related sidebar PRs and were not used as inventory proof. (2db1975aa72a)
  • Cutover and regeneration: Baseline compares the previous raw inventory against a fresh extraction without parsing the old format, so older or conflicted inventories can be regenerated. Android and Apple readers move together, Gradle tracks the new module, and the workflow includes it in trigger and invalidation paths. The member-authored body explicitly documents the one-time conflict for open v2 branches and its baseline repair. (scripts/native-app-i18n.ts:1127, 2db1975aa72a)
  • Regression coverage and review continuity: The merge regression exercises source extraction, serialization, real git merge-file, and equality with the combined baseline. The body records failure with the former serializer and passing focused checks. The previous completed review contained no findings or published rank-up moves. Tests were inspected but not executed during this read-only review. (test/scripts/native-app-i18n.test.ts:162, 2db1975aa72a)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-02T06:57:03.905Z sha 40f236a :: needs changes before merge. :: none
  • reviewed 2026-10-02T07:32:33.185Z sha 813e040 :: needs maintainer review before merge. :: none

@steipete
steipete enabled auto-merge (squash) October 2, 2026 15:40
@steipete
steipete merged commit f02d16e into main Oct 2, 2026
140 checks passed
@steipete
steipete deleted the steipete/native-i18n-inventory-v3 branch October 2, 2026 15:48
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…ventory (openclaw#163330)

The generated native inventory stored one line per string with every
extraction site inline, sorted alphabetically. Two PRs reusing a string
("Retry") both rewrote its line, and a feature's new strings ("Group by",
"Group chat") landed in the same insertion gap, so parallel native PRs
conflicted in apps/.i18n/native-source.json and needed a rebase plus a
full CI rerun.

Inventory v3 writes one line per extraction site, clustered by source
file, with clusters ordered by a hash of the path so new sibling files do
not share a gap. Each row's position depends only on its own content, so
independent edits merge cleanly (including GitHub's server-side merge)
and the merged text equals a fresh baseline. The new
scripts/native-i18n-inventory.ts owns serialization and parsing; the
generator, Android/Gradle and Apple readers migrate to it together and
receive the same entries in the same order as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant