Skip to content

fix(history): serialize collision rebuilds with appends - #5088

Merged
huangruiteng merged 2 commits into
loopx-project:mainfrom
Duang777:codex/fix-run-index-rebuild-lock
Sep 26, 2026
Merged

huangruiteng merged 2 commits into
loopx-project:mainfrom
Duang777:codex/fix-run-index-rebuild-lock

Conversation

@Duang777

Copy link
Copy Markdown
Collaborator

Summary

  • take the per-goal run-index lock for the complete collision rebuild transaction
  • serialize snapshot reads, recovery artifact creation, backup, and index replacement with normal append writers
  • add a deterministic concurrent regression test that pauses before replacement and proves a new append survives

Root cause

apply_reviewed_collision_rebuild rewrote index.jsonl from an unlocked snapshot. A normal run append could commit after that snapshot and then be overwritten by the rebuild replacement.

Validation

  • python -m pytest -q tests/test_history_index_write_serialization.py tests/test_history_chronology.py tests/control_plane/test_run_artifact_reservation.py tests/control_plane/test_quota_void_commit_runtime.py (33 passed)
  • python examples/history-index-duplicate-inspection-smoke.py
  • python -m mypy loopx/control_plane/runtime/run_index_rebuild.py
  • python -m ruff check loopx/control_plane/runtime/run_index_rebuild.py tests/test_history_index_write_serialization.py
  • python -m loopx.cli canary premerge --from-git-diff --tier standard --format json --no-progress (passed, 13 selected checks)
  • python examples/docs-governance-smoke.py

Known baseline failure

python examples/repository-hygiene-smoke.py reports the existing missing release timeline entry for v1.2.0; the same failure reproduces on unchanged origin/main.

Merge policy

Control-plane behavior change. Maintainer review and merge required; do not self-merge.

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>

@Duang777 Duang777 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head self-review for 67bc85d: APPROVE for maintainer review. The rebuild now holds the shared run-index lock across collision detection and replacement, and the regression test exercises a concurrent append during rebuild. All branch-specific CI checks passed. The remaining installed-artifact failure is the main-branch packaging defect tracked by #5096.

…ebuild-lock

Signed-off-by: duanjialing.777 <duanjialing.777@bytedance.com>

@Duang777 Duang777 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact-head self-review for f9e43f87735ae373aaa7e22e884efba4e68143cb: ready for maintainer review. This head merges origin/main@eaa0c0fd089e5844b763cc24132dcf8a3881c39b without conflicts and retains only the run-index serialization fix plus its regression test. Local validation passed: 33 focused Python tests, Ruff, Mypy, history-index smoke, docs governance, and the standard premerge gate with 13 checks.

@Duang777

Copy link
Copy Markdown
Collaborator Author

CI triage for exact head f9e43f87735ae373aaa7e22e884efba4e68143cb: all non-Python-shard checks passed, including PostgreSQL, release build, TypeScript, Windows, stage2c, and DCO. The four Python shards fail on the timeout-aware authority calls merged by #5063: existing test doubles reject the new timeout keyword, and the registry I/O manifest is stale. This branch changes only run-index rebuild code and its regression test; the same failures reproduce on current main. The isolated baseline repair is #5104. I am leaving this branch unchanged until that fix lands, then I will merge current main and rerun exact-head CI.

@huangruiteng
huangruiteng merged commit 4d22fc3 into loopx-project:main Sep 26, 2026
25 of 31 checks passed
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.

2 participants