Re-export the TinyMemory contract instead of duplicating it (tinymemory#18 §A1) - #149
Open
YellowSnnowmann wants to merge 1 commit into
Conversation
tinymemory#18 §A1. This crate and `tinymemory-api` described the same memory value types — `MemoryEntry`, `MemoryCategory`, `MemoryTaint`, `NamespaceSummary`, `RecallOpts`, `Capability`, the `provider::types` set — because the latter was extracted from the former and held byte-identical. They were the same code and nominally distinct types, so `adapters/tinycortex/src/convert.rs` in tinymemory had to translate between them on every call, and a field added to one had to be added to the other and to the conversion, in three places, or a value was silently dropped. `api/` now re-exports `tinymemory-api` and defines nothing of its own: 33 files deleted, `lib.rs` left as the re-export. Every existing path still resolves — `tinycortex_api::types::MemoryEntry` now *is* `tinymemory_api::types::MemoryEntry` — so no dependant needs an edit to gain the single type set. Two things change on purpose, both checked against the engine before doing this: - The capability vocabulary grows from thirteen families to eighteen. The engine matches on `Capability` in zero places, so nothing here is affected. - `CONTRACT_VERSION` becomes the contract's `(2, 2)` rather than this crate's `(1, 0)`. That value was already stale — hosts bind against the contract, and the engine never reads it. The enums the engine *does* match on are variant-identical (`MemoryCategory` at 16 sites, `MemoryTaint` at 9), so no match arm changes. The dependency is by git, which requires this crate not to publish — hence `publish = false` here and on the engine. That records the state the repository has actually been in rather than changing it: since `api/` was split out, `cargo package -p tinycortex` has failed with `no matching package named 'tinycortex-api' found`, because that crate was never published. The last release predates the split. A host that vendors both patches the git entry to its own checkout, so a build never resolves two copies. Validation, all from a clean clone at 5fdeac9: - `cargo check --workspace --all-targets` — clean - `cargo test --workspace` — 1259 passed, 0 failed - `cargo fmt --all -- --check` — clean - `cargo clippy --all-targets -- -D warnings` (the CI gate) — clean, 0 before and after - `cargo clippy --workspace --all-targets --all-features -- -D warnings` — 6 errors before and 6 after, all pre-existing in `persona/` and `sync/composio/` and untouched by this change Refs tinyhumansai/tinymemory#18 (§A1)
|
Caution Review failedAn error occurred during the review process. Please try again later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the tinycortex half of tinyhumansai/tinymemory#18 §A1.
The problem
This crate and
tinymemory-apidescribe the same memory value types —MemoryEntry,MemoryCategory,MemoryTaint,NamespaceSummary,RecallOpts,Capability, theprovider::typesset. Not by coincidence:tinymemory-apiwas extracted from this crate and held byte-identical.types.rsdiffers between them by 14 lines, and every one is a doc comment, a doctest path, or a single extra parse arm.They are the same code and nominally distinct types. So
adapters/tinycortex/src/convert.rsin tinymemory translates between them on every call, and a field added to one has to be added to the other and to the conversion — three places, or a value is silently dropped.The change
api/re-exportstinymemory-apiand defines nothing of its own. 33 files deleted;lib.rsis the re-export.Every existing path still resolves.
tinycortex_api::types::MemoryEntrynow istinymemory_api::types::MemoryEntry, so no dependant needs an edit to gain the single type set — andconvert.rsdownstream collapses to identity.Two deliberate changes, checked against the engine first
Capabilityin zero placesCONTRACT_VERSION(1,0) → (2,2)The enums the engine does match on are variant-identical —
MemoryCategory(16 sites) andMemoryTaint(9 sites) — so no match arm changes. I checked this before writing the re-export rather than after.Why
publish = falseThe dependency is by git, and cargo refuses a git dependency in a published crate.
This records the state the repository has actually been in rather than changing it. Since
api/was split out, publishing has been broken:tinycortex-apiwas never published, andtinycortexmain depends on it bypath + version. The last release (0.1.1, 29–30 June, 54 downloads) predates the split, so the release workflow would fail the next time it ran.A host that vendors both crates patches the git entry to its own checkout — as tinymemory's workspace root does — so a build never resolves two copies of the contract.
Validation
From a clean clone at
5fdeac9:cargo check --workspace --all-targetscargo test --workspacecargo fmt --all -- --checkcargo clippy --all-targets -- -D warnings(theci.ymlgate)cargo clippy --workspace --all-targets --all-features -- -D warningsThose 6 are pre-existing, in
persona/andsync/composio/, and untouched here — I measured the baseline on the unmodified commit rather than assuming.Merge order
tinymemory's companion change — deleting
convert.rsand simplifying the adapter — depends on this landing first, since it needs the gitlink bumped to a commit that carries the re-export.