Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 19 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"crates/tw-types",
"crates/tw-upstream",
"crates/tw-wire",
"crates/tw-resil",
"crates/tw-crypto",
# ── 第二层 · 桌面网关(企业版永不依赖)────────────────
"crates/tw-api",
Expand All @@ -16,7 +15,7 @@ members = [
"crates/tw-pricing",
"crates/tw-adopt",
"crates/tw-scan",
"crates/tw-redact",
"crates/tw-guard",
"crates/tw-dialect",
"crates/tw-engine",
"crates/tw-observe",
Expand All @@ -26,8 +25,6 @@ members = [
"bin/twcore",
]

# 其余 crate 在有内容时再加进来,不预先建空壳:
# tw-redact / tw-pricing / tw-engine / tw-guard / tw-store / tw-observe

[workspace.package]
edition = "2024"
Expand All @@ -45,7 +42,6 @@ version = "0.36.0"
tw-types = { path = "crates/tw-types" }
tw-upstream = { path = "crates/tw-upstream" }
tw-wire = { path = "crates/tw-wire" }
tw-resil = { path = "crates/tw-resil" }
tw-crypto = { path = "crates/tw-crypto" }
tw-api = { path = "crates/tw-api" }
tw-secret = { path = "crates/tw-secret" }
Expand All @@ -59,7 +55,7 @@ tw-store = { path = "crates/tw-store" }
tw-pricing = { path = "crates/tw-pricing" }
tw-adopt = { path = "crates/tw-adopt" }
tw-scan = { path = "crates/tw-scan" }
tw-redact = { path = "crates/tw-redact" }
tw-guard = { path = "crates/tw-guard" }
tw-dialect = { path = "crates/tw-dialect" }

# ── 版本与企业版 workspace 对齐,便于反向依赖时不打架 ────
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ Point a client (Claude Code, Codex, and friends) at a local port, and:
## Crate layers

```
tw-types · tw-dialect · tw-wire · tw-upstream · tw-resil · tw-crypto ← shape fixed by the outside world
tw-engine · tw-pricing · tw-redact · tw-yaml · tw-secret ← domain logic
tw-config · tw-store · tw-scan · tw-adopt · tw-observe ← assembly
tw-gateway · tw-control ← data plane / control plane
tw-types · tw-dialect · tw-wire · tw-upstream · tw-crypto ← shape fixed by the outside world
tw-engine · tw-pricing · tw-guard · tw-yaml · tw-secret ← domain logic
tw-config · tw-store · tw-scan · tw-adopt · tw-observe ← assembly
tw-gateway · tw-control ← data plane / control plane
```

The top two layers are stable against external reality — the server edition
Expand Down
8 changes: 4 additions & 4 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ cargo run -p twcore -- serve # 起网关和控制面
## crate 分层

```
tw-types · tw-dialect · tw-wire · tw-upstream · tw-resil · tw-crypto ← 形状由外部现实决定
tw-engine · tw-pricing · tw-redact · tw-yaml · tw-secret ← 领域逻辑
tw-config · tw-store · tw-scan · tw-adopt · tw-observe ← 装配
tw-gateway · tw-control ← 数据面 / 控制面
tw-types · tw-dialect · tw-wire · tw-upstream · tw-crypto ← 形状由外部现实决定
tw-engine · tw-pricing · tw-guard · tw-yaml · tw-secret ← 领域逻辑
tw-config · tw-store · tw-scan · tw-adopt · tw-observe ← 装配
tw-gateway · tw-control ← 数据面 / 控制面
```

上面两层对外部稳定,服务端版本直接依赖它们。下面两层是单机的实现
Expand Down
1 change: 1 addition & 0 deletions bin/twcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ anyhow = { workspace = true }
clap = { workspace = true }
tw-adopt = { workspace = true }
tw-scan = { workspace = true }
tw-guard = { workspace = true }
tw-wire = { workspace = true }
serde_yaml_ng = { workspace = true }
tokio = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions bin/twcore/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ fn main() -> Result<()> {
fn cmd_scan(_config: &Path, projects: Vec<PathBuf>, inventory: bool) -> Result<()> {
// **只用内置规则**,和应用里 MCP 页扫的是同一套。安全页上的规则只作用于
// 经过网关的请求
let rules = tw_scan::rules::scan_rules();
let rules = tw_guard::tools::rules::scan_rules();
let mut srcs = tw_scan::sources::user_level(&home());
for p in &projects {
srcs.extend(tw_scan::sources::in_project(p));
Expand Down Expand Up @@ -630,7 +630,7 @@ fn cmd_check(path: &Path) -> Result<()> {
// **本机的 http 不算明文过网。**报它是个假警报,而
// 假警报的代价是用户学会忽略这一栏的所有话(
// 没有风险的时候要说「安全」,不是把话说满)。
// tw-redact 的内网规则出于同一个理由排除回环。
// tw-guard 的内网规则出于同一个理由排除回环。
let loopback = o.endpoint.starts_with("http://127.0.0.1")
|| o.endpoint.starts_with("http://localhost")
|| o.endpoint.starts_with("http://[::1]");
Expand Down
4 changes: 2 additions & 2 deletions bin/twcore/tests/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ fn product_text_is_written_not_spoken() {
}

// 内置扫描规则的说明会原样出现在发现和工具调用告警里
let rules = root.join("crates/tw-config/data/rules.yaml");
let rules = root.join("crates/tw-guard/data/rules.yaml");
for (n, l) in std::fs::read_to_string(&rules).unwrap().lines().enumerate() {
let Some(why) = l.trim().strip_prefix("why:") else {
continue;
};
for w in SPOKEN.iter().filter(|w| why.contains(**w)) {
found.push(format!(
"crates/tw-config/data/rules.yaml:{} 「{w}」 {why}",
"crates/tw-guard/data/rules.yaml:{} 「{w}」 {why}",
n + 1
));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tw-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tw-types = { workspace = true }
tw-api = { workspace = true }
tw-secret = { workspace = true }
# 校验要认得出配置里写到的内置脱敏规则 id
tw-redact = { workspace = true }
tw-guard = { workspace = true }
regex = { workspace = true }
tw-pricing = { workspace = true }
# 凭据轮换要把一个标量写回 config.yaml。**span 补丁,不是
Expand Down
4 changes: 2 additions & 2 deletions crates/tw-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,8 +954,8 @@ pub fn write(path: &Path, cfg: &Config) -> Result<(), WriteError> {
pub use probes::{ClientProbes, ProbeAction};
pub use reload::{Rejected, Stage, try_parse};
pub use security::{
BUILTIN_RULES, CustomRedactRule, CustomToolRule, Mode as SecurityMode, RedactPolicy, Security,
ToolAction, ToolPolicy,
CustomRedactRule, CustomToolRule, Mode as SecurityMode, RedactPolicy, Security, ToolAction,
ToolPolicy,
};
// Billing 在本文件里定义,这里不必再导出
pub use store::{Fingerprint, Loaded, StoreError, version_of};
Expand Down
Loading
Loading