refactor!: keep only what both gateways use in the shared layer - #164
Merged
Merged
Conversation
A shared component used by only one side moves back to that side. After this, the server edition depends on tw-dialect, tw-guard and tw-breaker and nothing else. - tw-wire is merged into tw-dialect as `tw_dialect::usage`. There is one `Usage` (the IR one, now with `cache_1h`), and the sniffer hands each usage object to the dialect's own `usage()` parser instead of carrying a second copy of every formula. The Anthropic parser now reads the 1h cache-write breakdown, which only the sniffer understood before. - tw-upstream is split: `upstream_url` and the gateway-key stripping move to `tw_dialect::url` (`without_gateway_key` is public for the WS path); the header helpers move into tw-gateway's `forward`; SigV4 and eventstream unframing move to the server edition, along with the bedrock-feature CI step. - tw-crypto moves to the server edition (the desktop never used it). - tw-types keeps only `Msg`/`msg!`. The unused chat DTOs are deleted; `GatewayError`, `CallCtx` and friends move to the server edition; `Retention` and `PRIVATE_RANGES` move into tw-config. - tw-guard inlines its one masking helper and no longer pulls tw-secret into the server edition. - A test (`tw-dialect/tests/layer_one.rs`) fails if a layer-one crate depends on a layer-two one, and a new CI job builds the server edition against every change to layer one, using a same-named ThinkWatch branch when one exists and `dev` otherwise. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 24, 2026
Merged
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.
A shared component used by only one side moves back to that side. After this, the server edition (ThinkWatch) depends on tw-dialect, tw-guard and tw-breaker and nothing else.
What moved where
tw-wire(usage sniffing)tw_dialect::usage. OneUsage(the IR one, now withcache_1h). The sniffer hands each usage object to the dialect's ownusage()parser, so every formula (Gemini's, OpenAI's cache subtraction, …) exists once. The Anthropic parser now reads the 1h cache-write breakdown, which only the sniffer understood before.tw_upstream::upstream_url+key=strippingtw_dialect::url(without_gateway_keyis public, for the WS path)tw_upstreamheader helpers (STRIP,forward_headers*,apply_headers,overridden,response_headers,gemini_path_with_model)forward(desktop only)tw_upstream::{sigv4, eventstream}+ thebedrock_streamtest + the bedrock-feature CI steptw-cryptotw-types: chat DTOstw-types:GatewayError,CallCtx,substitute_template,parse_retry_after_secondstw-types:Retention,PRIVATE_RANGEStw-guard→tw-secret(onemask_secret)tw-typesnow holds onlyMsg/msg!and is desktop-only, as istw-secret.Guards
crates/tw-dialect/tests/layer_one.rsrunscargo metadataand fails if a layer-one crate depends on a layer-two one (checked by addingtw-secretback to tw-guard: it fails withtw-guard → tw-secret).dev), patches the three layer-one crates to this checkout, and runscargo check --workspace --all-targets. ThinkWatch has nosqlx::query!macros, so no database is needed. This PR's counterpart is the same-named ThinkWatch branchrefactor/shared-layer-one-side.Checks
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(proxy unset) — all green.--all-targetsand--lib), and unit tests are all green.Cargo
Cargo.tomlmember comments and both READMEs' "Crate layers" sections describe the new split.🤖 Generated with Claude Code