refactor(pack): extract helper functions from encode.rs to improve testability#136
refactor(pack): extract helper functions from encode.rs to improve testability#136p05-HY wants to merge 105 commits into
Conversation
Signed-off-by: Quanyi Ma <eli@patch.sh>
init codebase
Signed-off-by: Neon <neonkk@qq.com>
Signed-off-by: Neon <neonkk@qq.com>
Signed-off-by: Neon <neonkk@qq.com>
Signed-off-by: Neon <neonkk@qq.com>
Signed-off-by: Neon <neonkk@qq.com>
fix: mercury compilation
Signed-off-by: Eli Ma <eli@patch.sh>
Signed-off-by: Eli Ma <eli@patch.sh>
Fix tests case
…tion#4) Signed-off-by: Quanyi Ma <eli@patch.sh>
* Add r2cn issue template Signed-off-by: Quanyi Ma <eli@patch.sh> * Add documentations and update issue templates Signed-off-by: Quanyi Ma <eli@patch.sh> --------- Signed-off-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
…ndation#8) Resolves web3infra-foundation#6 Signed-off-by: allure <1550220889@qq.com>
add .devcontainer
Signed-off-by: Quanyi Ma <eli@patch.sh>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add dependabot config and update issue templates
Signed-off-by: allure <1550220889@qq.com>
Signed-off-by: allure <1550220889@qq.com>
Signed-off-by: allure <1550220889@qq.com>
…otocal feat: Abstract HTTP and SSH protocal from mega to git-internal
Signed-off-by: allure <1550220889@qq.com>
* Add copilot-instructions.md for GitHub copilot Signed-off-by: Eli Ma <eli@patch.sh> * Update .github/copilot-instructions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/copilot-instructions.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Signed-off-by: Eli Ma <eli@patch.sh> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Update git protocol doc and reformat core.rs
Signed-off-by: Eli Ma <eli@patch.sh>
* add ai_obj and update buck Signed-off-by: jackie <jackieismpc@gmail.com> * refactor project and fix some bugs Signed-off-by: jackie <jackieismpc@gmail.com> * restore hash Signed-off-by: jackie <jackieismpc@gmail.com> * update checksum Signed-off-by: jackie <jackieismpc@gmail.com> * update base object Signed-off-by: jackie <jackieismpc@gmail.com> * update process object Signed-off-by: jackie <jackieismpc@gmail.com> * update doc Signed-off-by: jackie <jackieismpc@gmail.com> * update seal Signed-off-by: jackie <jackieismpc@gmail.com> * refactor base Signed-off-by: jackie <jackieismpc@gmail.com> * update ai_hash Signed-off-by: jackie <jackieismpc@gmail.com> * splite objects Signed-off-by: jackie <jackieismpc@gmail.com> * update docs Signed-off-by: jackie <jackieismpc@gmail.com> * rename objects Signed-off-by: jackie <jackieismpc@gmail.com> --------- Signed-off-by: jackie <jackieismpc@gmail.com>
* Update objects of agent flow Signed-off-by: Quanyi Ma <eli@patch.sh> * Fix zstdelta test Signed-off-by: Eli Ma <eli@patch.sh> * Fix copilot warnings Signed-off-by: Eli Ma <eli@patch.sh> * Update claude review action Signed-off-by: Eli Ma <eli@patch.sh> * Update claude review action Signed-off-by: Eli Ma <eli@patch.sh> --------- Signed-off-by: Quanyi Ma <eli@patch.sh> Signed-off-by: Eli Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
…y enforcement (web3infra-foundation#99) * Apply AI object and context fixes Signed-off-by: Quanyi Ma <eli@patch.sh> * ai-objects: apply review feedback and tighten invariants Signed-off-by: Quanyi Ma <eli@patch.sh> * Fix fmt Signed-off-by: Quanyi Ma <eli@patch.sh> * Fix critical issues from PR web3infra-foundation#98 review - Fix Header::seal() checksum integrity bug: remove updated_at mutation after checksum computation so the checksum matches the final object state - Fix Intent error variants: use InvalidIntentObject instead of generic InvalidObjectInfo in from_bytes() and to_data() - Fix semantic versioning: bump to 0.6.0 (not 0.5.1) since PR web3infra-foundation#98 added new public types, enum variants, and trait methods Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> * Reject AI object types in pack encode/decode paths AI extension types (ContextSnapshot, Decision, etc.) use u8 IDs >= 8 which cannot fit in the 3-bit pack header type field (values 1-7). Previously, the decode path silently returned Ok(None) for these types (dead code since from_pack_type_u8 already rejects them), and the parallel_encode path lacked an early check, letting AI objects fail deep in encode_one_object with a generic error. - Add ObjectType::is_ai_object() helper for classifying AI extensions - Replace silent Ok(None) in decode with explicit InvalidPackFile error - Add early AI type rejection in parallel_encode before batching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> * ai-objects: update project metadata and documentation Update Cargo.toml description/keywords/categories, README.md overview and AI Object Model section, and CLAUDE.md with comprehensive AI object model guidance including end-to-end flow, file mapping, key patterns, and documentation links. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> * Fix backward compatibility for PlanStep.statuses and Header.updated_at - PlanStep.statuses: add #[serde(default)] with a Pending-entry default so legacy plans with the old single `status` field can still deserialize. - Header.updated_at: replace Utc::now() default with a custom Deserialize impl that falls back to created_at, avoiding nondeterministic metadata when loading legacy objects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> * Address code review: fix panics, frame stability, seal semantics, is_base - ObjectType::to_bytes() returns Option instead of panicking on delta types; callers updated (pack/utils.rs, zlib/inflate.rs) - Intent::status() and PlanStep::status() return Option instead of panicking via expect() on potentially empty statuses Vec - ObjectType::is_base() returns false for AI types (they cannot participate in pack delta window selection) - ContextFrame gains stable frame_id assigned by ContextPipeline's monotonic counter; PlanStep iframes/oframes changed from Vec<u32> indices to Vec<u64> frame IDs that survive eviction - Header::seal() now updates updated_at timestamp - Updated docs/ai.md with frame ID semantics and usage examples Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> --------- Signed-off-by: Quanyi Ma <eli@patch.sh> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: Eli Ma <eli@patch.sh>
Signed-off-by: jl.jiang <jiangjl9807@gmail.com>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
…#108) * chore: bump chrono to 0.4.44 and uuid to 1.21.0 Signed-off-by: Steven <fyoylf@gmail.com> * chore: remove claude-review workflow Signed-off-by: Steven <fyoylf@gmail.com> --------- Signed-off-by: Steven <fyoylf@gmail.com>
* chore: align intent pipeline lifecycle and comments Signed-off-by: Quanyi Ma <eli@patch.sh> * docs: add agent and protocol documentation set Signed-off-by: Quanyi Ma <eli@patch.sh> * refactor: replace plan fwindow with iframes and update docs Signed-off-by: Quanyi Ma <eli@patch.sh> * docs: expand agent object documentation Signed-off-by: Quanyi Ma <eli@patch.sh> * feat: add agent event objects Signed-off-by: Quanyi Ma <eli@patch.sh> * refactor: address review feedback on object model - Remove clone-on-copy in intent_event.rs - Delegate ObjectTrait::object_hash to ObjectHash::from_type_and_data - Add ObjectType round-trip tests for variant coverage - Include mismatched intent IDs in Plan error message - Replace ParentLike trait with direct &[Uuid] parameter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> * Document and refine intent workflow model Signed-off-by: Quanyi Ma <eli@patch.sh> * ci: add crates.io publish workflow on tag push Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Quanyi Ma <eli@patch.sh> * ci: add least-privilege permissions to publish workflow Signed-off-by: Quanyi Ma <eli@patch.sh> --------- Signed-off-by: Quanyi Ma <eli@patch.sh> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Upgrade some crates Signed-off-by: Eli Ma <eli@patch.sh> * Upgrade commit Signed-off-by: Eli Ma <eli@patch.sh> --------- Signed-off-by: Eli Ma <eli@patch.sh>
* Replace bincode with rkyv 0.8.15 Signed-off-by: Quanyi Ma <eli@patch.sh> * Declare rkyv bytecheck feature explicitly Signed-off-by: Quanyi Ma <eli@patch.sh> * Harden pack cache spill format handling Signed-off-by: Quanyi Ma <eli@patch.sh> * Fix rustfmt formatting in cache spill code Signed-off-by: Quanyi Ma <eli@patch.sh> * Harden atomic cache spill writes Signed-off-by: Quanyi Ma <eli@patch.sh> * Refine pack cache spill review fixes Signed-off-by: Quanyi Ma <eli@patch.sh> * Avoid clobbering existing pack cache files Signed-off-by: Quanyi Ma <eli@patch.sh> * Skip redundant pack cache re-encoding Signed-off-by: Quanyi Ma <eli@patch.sh> * Align pack cache spill save and tests Signed-off-by: Quanyi Ma <eli@patch.sh> --------- Signed-off-by: Quanyi Ma <eli@patch.sh>
…ra-foundation#118) Bumps the cargo group with 1 update in the / directory: [time](https://github.com/time-rs/time). Updates `time` from 0.3.44 to 0.3.47 - [Release notes](https://github.com/time-rs/time/releases) - [Changelog](https://github.com/time-rs/time/blob/main/CHANGELOG.md) - [Commits](time-rs/time@v0.3.44...v0.3.47) --- updated-dependencies: - dependency-name: time dependency-version: 0.3.47 dependency-type: indirect dependency-group: cargo ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
Signed-off-by: Quanyi Ma <eli@patch.sh>
…stability Split complex functions in PackEncoder into smaller, testable units while preserving all existing pack encoding semantics. Changes: 1. Add TypedEntryBuckets struct to represent classified object buckets 2. Extract classify_entries_by_type() from inner_encode() for object classification 3. Extract sort_entry_buckets() from inner_encode() for bucket sorting 4. Extract score_delta_candidate() from try_as_offset_delta() for delta base evaluation New unit tests (5): - test_classify_entries_by_type_groups_supported_objects - test_classify_entries_by_type_rejects_delta_objects - test_sort_entry_buckets_uses_magic_sort_for_each_type - test_score_delta_candidate_rejects_unsuitable_bases - test_score_delta_candidate_accepts_similar_content All existing tests pass (218 unit tests, 4 integration tests, 1 doctest). cargo clippy -D warnings and cargo fmt --check pass. No behavioral changes to pack encoding output.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe7d454417
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if name.starts_with(prefix) && name.ends_with(".pack") { | ||
| return entry.path(); |
There was a problem hiding this comment.
Ensure pack fixtures are available without LFS smudge
In clones where Git LFS has not been pulled, find_pack now returns the checked-in LFS pointer file because the previous download fallback was removed and the new fixtures are LFS-managed. The decoder then reads version ... instead of the PACK magic and these integration tests fail before exercising the pack code; please either retain a fetch/fallback path or validate/fetch the LFS object before returning the path.
Useful? React with 👍 / 👎.
- Use sort_by_key instead of sort_by in pack_index.rs - Collapse nested if into match guard in pack.rs
|
@genedna CI is green ✅. Please take a look when you have time. Thanks! |
|
@genedna Sorry for the close, accidentally clicked. PR is ready for review. Thanks! |
|
@genedna CI is green ✅. Please take a look when you have time. Thanks! |
|
@genedna ,Hi maintainers, just a gentle ping on this PR. All CI checks have passed. Is there anything else needed from my side? Thanks! |
Split complex functions in PackEncoder into smaller, testable units
while preserving all existing pack encoding semantics.
Changes:
New unit tests (5):
Testing:
Behavior:
No behavioral changes to pack encoding output.