Skip to content

fix(lexical): carry text artifact across added and removed files - #3073

Open
devin-ai-integration[bot] wants to merge 14 commits into
masterfrom
devin/1791126041-lexical-roster-carry
Open

devin-ai-integration[bot] wants to merge 14 commits into
masterfrom
devin/1791126041-lexical-roster-carry

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • An edit that adds, removes, or renames a file now carries the parent lexical text artifact and re-encodes only the affected files. Previously, it fell back to a cold build of the whole corpus.
  • The carried artifact remains byte-identical to a cold build of the same tree.

Fixes #2906
Fixes #2880

Cause

The earlier carry fixes handled only edits that kept the same file roster. changed_files_since returned None when the file count or any file key differed, so adding or removing a file caused a full re-encode. Under a 6 GiB cap, a full-clone edit then rebuilt the whole corpus.

Changes

  • VerifiedSealedLexicalPageSourceV1::file_replacements_since replaces changed_files_since. It verifies that both sources cut pages the same way, then calls the pure file_replacement_runs function. That function walks both rosters by logical path. Paths strictly ascend in build order. It returns SealedLexicalFileReplacementV1 runs from parent_files to files, and either side of a run can be empty. It returns None when page-cut inputs differ or paths do not strictly ascend. In those cases, the build remains cold.
  • partitioned_codec: replaces the roster comparison with the file_keys() and same_segment() primitives.
  • increment.rs: stage_replaced_files stages each run's successor files at the cold position and verifies that the runs ascend together. rewrite_page_rows now also shifts source_pages.file_ordinal by the net file growth of earlier runs. Document, page, and clone shifting is unchanged and operates per run.
  • serving.rs: the existing 1/8 cold-fallback threshold now counts replaced files as max(parent, successor) for each run.

Test plan

  • New behavior test an_added_or_removed_file_carries_the_parent_text_artifact_byte_identical_to_a_cold_build. It hides every parent segment while the successor builds, so a cold fallback cannot finish. The test then requires the carried bytes to equal a cold build across six rounds: add a file, remove a file, replace a file with its neighbour alongside a body edit, rename a file, add a new first file, and remove the last file.
    • Without this change, it fails with Contract("sealed generation segment is unavailable ..."). With this change, bash scripts/require-exact-test.sh cargo test -p tracedecay-code-index-runtime --lib code_index_scheduler::tests::text_artifact_carry_tests::an_added_or_removed_file_carries_the_parent_text_artifact_byte_identical_to_a_cold_build -- --exact passes with 1 test passed.
  • New unit test file_replacement_runs_align_rosters_by_path checks exact runs against literal values. Cases cover no change, a single edit, additions and removals at both ends of the roster, an addition next to a removal as one run, an edit that extends a preceding replacement, every file replaced, and every file removed. bash scripts/require-exact-test.sh cargo test -p tracedecay-code-index --lib production::lexical_page_source::lexical_page_source_tests::file_replacement_runs_align_rosters_by_path -- --exact passed with 1 test passed.
  • cargo test -p tracedecay-code-index-runtime --lib -- text_artifact (26 passed), cargo test -p tracedecay-query --lib -- lexical::projection::artifact (84 passed), cargo test -p tracedecay-code-index --lib -- lexical (14 passed)
  • cargo fmt --all -- --check; cargo clippy -p tracedecay-code-index -p tracedecay-query -p tracedecay-code-index-runtime --all-targets -- -D warnings is clean
  • cargo nextest run --workspace --no-fail-fast (left to CI)

Checklist

  • CHANGELOG.md updated (release-please generates it from the commit)
  • No secrets, credentials, or .env files included
  • Breaking changes documented: none. changed_files_since was used only inside the workspace.

Link to Devin session: https://app.devin.ai/sessions/b676368291d446d1b33cd48d4dd5afad
Open in Devin Desktop: https://app.devin.ai/desktop/session/b676368291d446d1b33cd48d4dd5afad?variant=devin
Requested by: @ScriptedAlchemy


Devin Review

Align parent and successor files by path so a roster change re-encodes
only the replaced runs and shifts every later file ordinal, instead of
falling back to a cold whole-corpus build.

Refs #2906, #2880

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bb64967

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

ScriptedAlchemy and others added 13 commits October 4, 2026 18:57
Extract the path merge-walk into file_replacement_runs and unit-test
additions and removals at both roster ends, merged neighbour runs, and
full replacement; add first/last roster rounds to the byte-identical
carry test.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant