Skip to content

Commit 0a9e3cb

Browse files
authored
Merge pull request #35 from A3S-Lab/chore/sync-sentry-decoupled-l3-20260720
docs: sync Sentry decoupled L3 safeguards
2 parents d17d265 + bd94a90 commit 0a9e3cb

13 files changed

Lines changed: 127 additions & 23 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ is Rust.
6565
| [a3s-runtime](crates/runtime/) | 0.2.0 | Provider-neutral execution contract and Runtime client. |
6666
| [a3s-box](crates/box/) | 3.0.5 | Docker-like MicroVM runtime for Linux OCI workloads. |
6767
| [a3s-observer](crates/observer/) | 0.11.0 | eBPF observability for LLM calls, tools, files, and egress. |
68-
| [a3s-sentry](crates/sentry/) | 0.7.0 | Tiered runtime security control. |
68+
| [a3s-sentry](crates/sentry/) | 0.7.0 | Tiered runtime security control with staged L3 dispatch and incomplete-evidence safeguards. |
6969
| [a3s-boot](crates/boot/) | 0.1.1 | Nest-inspired modular service framework for Rust APIs. |
7070
| [a3s-gateway](crates/gateway/) | 1.0.12 | Reverse proxy, routing, middleware, streaming, and scale-to-zero. |
7171
| [a3s-power](crates/power/) | 0.4.2 | Privacy-preserving LLM inference for TEE environments. |

apps/docs/content/docs/cn/sentry/configuration.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,16 @@ rules = [
128128

129129
## Fail Mode
130130

131-
Sentry 默认 fail-open。L1 escalate 后如果没有更深 tier 给出结论,该事件会 allow。慢 tier 导致 queue overload 时也遵循同样姿态
131+
Sentry 默认 fail-open。L1 escalate 后如果没有更深 tier 给出结论,该事件会 allow。完整 evidence 的 escalation 被满 worker queue 拒绝时也遵循同样姿态
132132

133133
Fail-closed 会把 unresolved escalation 和 overload degradation 变成 block。只有在 L2/L3 容量和 operational blast radius 都明确时,才适合安全优先 workload。
134134

135+
Incomplete `ToolExec` evidence 刻意采用不同语义。危险的已捕获 prefix 仍可
136+
block,但模糊的 truncated 或 incompletely reassembled command 在两种 fail mode
137+
下都会保留为 L1 escalation。Bundled daemon 会 audit 这个 unresolved result,
138+
包括 worker overload 场景;durable external L3 dispatch 应由 staged SDK
139+
consumer 负责。
140+
135141
## Deny Sinks
136142

137143
Deny file 是 append-only operational state。Sentry 写入 egress、file、exec target;Observer guard 执行。缺少 deny sink 也是合法的,此时进程只用于 judgment 或 dry-run analysis。
@@ -145,4 +151,7 @@ Exec deny 以路径为中心。对裸 binary name 的 deny action 可能无法
145151
- `GET /metrics`,包含 judged events、blocks、overload degradation、enforce failures 等 counters。
146152
- `GET /healthz`,daemon 存活时返回 `200 ok`
147153

148-
应重点告警 `sentry_overload_degraded_total``sentry_enforce_failed_total`;它们都表示预期 block 可能没有落地。
154+
应重点告警 `sentry_overload_degraded_total`
155+
`sentry_enforce_failed_total`。前者统计被满 worker queue 拒绝的
156+
escalation:完整 evidence event 使用 fail mode,incomplete command evidence
157+
保持 unresolved;后者表示 deny-file write 失败。

apps/docs/content/docs/cn/sentry/deployment-runbook.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Manifest 默认启用 dry-run,让首次 rollout 先 shadow policy decisions,
5656

5757
| Metric | 为什么重要 | 第一反应 |
5858
| --- | --- | --- |
59-
| `sentry_overload_degraded_total` | Worker queue 满了,escalation 只能落到 fail mode。 | 增加 workers 或 queue,减少 escalation volume,调慢 tier,或有意识地选择 fail-closed。 |
59+
| `sentry_overload_degraded_total` | Escalation 被满 worker queue 拒绝。完整 evidence 使用 fail mode;incomplete command evidence 保持 unresolved| 增加 workers 或 queue,减少 escalation volume,调慢 tier,或为完整 evidence overload 有意识地选择 fail-closed。 |
6060
| `sentry_enforce_failed_total` | 某个 block 需要写 deny file,但写入失败。 | 检查 volume space、mount mode、file permissions 和 configured paths。 |
6161

6262
`sentry_events_total``sentry_blocked_total` 用于观察流量与 block ratio trend。`/healthz` 只说明 daemon 存活,不证明每个 deny 都已落地。
@@ -73,7 +73,9 @@ L1 在每个 event 上运行并保持低成本。Escalation 进入 bounded worke
7373
- `A3S_SENTRY_AGENT_TIMEOUT`:L3 A3S Code investigation timeout。
7474
- `A3S_SENTRY_SPECULATE`:高 severity event 值得并行 L2/L3 时启用。
7575

76-
如果 overload 上升,说明当前部署对 event mix 来说资源不足,或 deeper tier 对 escalation rate 来说太慢。
76+
如果 overload 上升,说明当前部署对 event mix 来说资源不足,或 deeper tier
77+
对 escalation rate 来说太慢。完整 evidence event 按 fail mode 解决;
78+
incomplete `ToolExec` evidence 保持为 audited L1 escalation。
7779

7880
## L2 Or L3 Outage
7981

@@ -97,5 +99,6 @@ Sentry restart 期间,Observer guards 仍可继续执行已有 deny files。
9799

98100
- Observer-event Sentry 是 reactive。它能 block 下一次匹配动作,不一定能 block 产生 event 的那一次动作。
99101
- Inline Gateway inspection 是路由到 proxy 的 LLM/MCP traffic 的 pre-forward path。
102+
- Bundled daemon 会 audit incomplete-evidence escalation,但不提供 durable external L3 queue;staged SDK consumer 必须负责持久化和 dispatch。
100103
- Deny 是 coarse 且 node-local 的:IP 或 executable-path block 可能影响同 node 上其它 workload。
101104
- L2 和 L3 会处理 attacker-influenced content。确定性的 L1 和 kernel guard enforcement 仍应作为底线。

apps/docs/content/docs/cn/sentry/operations.mdx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ Guard 会热加载这些文件。Deny files 是运行态,不是 source-of-trut
2727

2828
| Metric | 含义 |
2929
| --- | --- |
30-
| `sentry_overload_degraded_total` | Escalation 无法处理,落入配置的 fail mode。 |
30+
| `sentry_overload_degraded_total` | Escalation 被满 worker queue 拒绝。完整 evidence 使用 fail mode;incomplete command evidence 保持 unresolved|
3131
| `sentry_enforce_failed_total` | Decision 需要 enforce,但写 deny record 失败。 |
3232
| `sentry_blocked_total` | 按 tier 和 event family 统计 block。 |
3333
| `sentry_events_total` | 总判断事件数。 |
3434

35-
在 fail-open 部署中,overload degradation 或 enforce failure 都意味着某次 block 可能没有落地。
35+
任何非零 overload rate 都表示 worker pool 资源不足。在 fail-open 部署中,
36+
完整 evidence 的 overflow 或 enforce failure 意味着某次 block 可能没有落地。
3637

3738
## Queue 和 Timeout 调优
3839

@@ -44,8 +45,14 @@ L2 和 L3 在 ingest thread 之外的 worker pools 运行。需要调:
4445
- 深度 A3S Code investigation 的 L3 timeout。
4546
- 高 severity event 是否值得 L2/L3 parallel 的 speculation threshold。
4647

48+
完整 evidence 的 queue overflow 会按配置 fail mode 解决。Incomplete
49+
`ToolExec` evidence 即使在 overload 时也保持为 audited L1 escalation。
50+
4751
## 边界
4852

4953
- Observer-event Sentry 是 reactive;它可能阻断下一步 action,而不是产生 event 的那一步。
54+
- Bundled daemon 会 audit incomplete-evidence escalation,但不提供 durable
55+
external L3 queue。需要 deeper work 时,staged SDK consumer 必须负责持久化
56+
和 dispatch。
5057
- Deny 可能比较粗:binary path 与 IP-based enforcement 可能影响同节点上的多个进程。
5158
- L2/L3 会读取攻击者影响的内容。确定性的 L1 底线和外部 kernel guard 仍然重要。

apps/docs/content/docs/cn/sentry/pipeline.mdx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Pipeline
3-
description: L1 rules、L2 LLM、L3 A3S Code investigation、SAE signals、fail posture 与 speculative parallelism
3+
description: L1 rules、L2 LLM、staged L3 dispatch、incomplete-evidence safeguards、SAE signals、fail posture 与 speculation
44
---
55

66
# Sentry Pipeline
@@ -34,13 +34,24 @@ ACL policy 文件提供,并支持热加载。
3434

3535
L1 是快速 triage 层,不是 sandbox。它刻意保守:遇到模糊情况就 escalate,而不是猜测。
3636

37+
对于 `ToolExec`,Observer 会在无法捕获完整 command 时报告
38+
`argv_truncated``argv_incomplete`。危险的已捕获 prefix 仍可直接 block;
39+
其它不明确的 incomplete command 会保留为 L1 escalation。进程内 L2/L3 judge
40+
不会猜测缺失 suffix 是 benign。
41+
3742
## L2 和 L3
3843

3944
L2 是事件分类器,适合 false-positive reduction 和快速语义判断。
4045

4146
L3 是真实 A3S Code agent。它加载安全技能,考虑 actor、观察到的 event、可能 attack chain
4247
和 blast radius,然后返回结构化 verdict。它更慢,但更深。
4348

49+
需要把快速判断与深度 investigation 分离的产品可以调用
50+
`Pipeline::evaluate_through_l2`。它返回 L1 decision、可选 L2 decision、
51+
effective decision、stage status 和 escalation cause,且不会调用 L3、
52+
应用 `fail_closed` 或启动 speculative L3。`Escalated` result 是需要持久化并
53+
dispatch 到 durable external L3 worker 的工作,不是 allow。
54+
4455
## Speculation
4556

4657
默认情况下,L3 只在 L2 escalate 后启动。开启 speculative parallelism 后,高 severity
@@ -53,3 +64,6 @@ Sentry 默认 fail-open:无法解决的 escalation 会 allow。只有在部署
5364
或采用能承受 unknown blocking 的 allow-list 姿态时,才应启用 fail-closed。
5465

5566
Rules-only fail-open 模式能执行直接 `block` 的规则,但不会执行只 `escalate` 的规则。
67+
Incomplete `ToolExec` evidence 是例外:无论 fail mode 如何,它都保留为
68+
unresolved L1 escalation。Bundled daemon 会 audit 这个 result,但不提供
69+
durable external L3 queue。

apps/docs/content/docs/cn/sentry/sdk.mdx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,28 @@ enforced = sentry.evaluate_and_enforce(tool_exec(2, ["/usr/bin/ncat", "host", "4
2323

2424
## TypeScript
2525

26-
TypeScript SDK 通过 native package 暴露同一个 judge:
26+
TypeScript SDK 通过 native package 暴露同一个 judge。Staged method 在 N-API
27+
worker pool 上运行并返回 typed promise:
2728

2829
```ts
29-
import { Sentry, egress } from '@a3s-lab/sentry';
30+
import { Sentry, egress, fileAccess } from '@a3s-lab/sentry';
3031

3132
const sentry = Sentry.create('sentry.acl');
3233
const decision = sentry.evaluate(egress(1, '169.254.169.254', 80));
34+
35+
const fast = await sentry.evaluateThroughL2(
36+
fileAccess(2, '/home/agent/.aws/credentials', false),
37+
);
38+
if (fast.stageStatus === 'escalated') {
39+
await durableL3Queue.send(fast);
40+
}
3341
```
3442

43+
`evaluateThroughL2` 不会调用 L3,也不会通过 `fail_closed` 解决 unresolved
44+
escalation。它的 `ThroughL2Result` 包含 `l1Decision`、可选
45+
`l2Decision``effectiveDecision``stageStatus` 和可选
46+
`escalationCause`
47+
3548
## 统一 ACL 配置
3649

3750
SDK 配置可以描述:
@@ -48,3 +61,7 @@ SDK 配置可以描述:
4861

4962
Rust host 可以直接用 `LiveRules``Pipeline` 和 judge implementations 构建 pipeline。
5063
当产品已经拥有 event source 和 enforcement sinks 时,这是最低层集成路径。
64+
65+
当产品还拥有 durable L3 queue 时,使用 `Pipeline::evaluate_through_l2`
66+
这个 method 在 fast tiers 后停止并保留 unresolved escalation;caller 必须
67+
持久化并 dispatch 该 result,不能把它当作 allow。

apps/docs/content/docs/en/sentry/configuration.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,16 @@ For committed samples, prefer environment substitution in the host application o
128128

129129
## Fail Mode
130130

131-
Sentry defaults to fail-open. If L1 escalates and no deeper tier resolves the event, the event is allowed. The same posture applies when a slow tier overloads the queue.
131+
Sentry defaults to fail-open. If L1 escalates and no deeper tier resolves the event, the event is allowed. Complete-evidence escalations rejected by a full worker queue use the same posture.
132132

133133
Fail-closed changes unresolved escalation and overload degradation into blocks. Use it for safety-first workloads only when L2/L3 capacity and the operational blast radius are understood.
134134

135+
Incomplete `ToolExec` evidence is deliberately different. A dangerous captured
136+
prefix can still block, but an ambiguous truncated or incompletely reassembled
137+
command remains an L1 escalation in both fail modes. The bundled daemon audits
138+
the unresolved result, including during worker overload; durable external L3
139+
dispatch belongs to a staged SDK consumer.
140+
135141
## Deny Sinks
136142

137143
Deny files are append-only operational state. Sentry writes egress, file, and exec targets; Observer guards enforce them. Missing deny sinks are valid when the process is used only for judgment or dry-run analysis.
@@ -145,4 +151,7 @@ Exec deny is path-oriented. A deny action on a bare binary name may not map to a
145151
- `GET /metrics` with counters for judged events, blocks, overload degradation, and enforce failures.
146152
- `GET /healthz` with `200 ok` while the daemon is alive.
147153

148-
Alert on `sentry_overload_degraded_total` and `sentry_enforce_failed_total`; both indicate that an intended block may not have landed.
154+
Alert on `sentry_overload_degraded_total` and `sentry_enforce_failed_total`.
155+
The first counts escalations rejected by the full worker queue:
156+
complete-evidence events use the fail mode, while incomplete command evidence
157+
remains unresolved. The second means a deny-file write failed.

apps/docs/content/docs/en/sentry/deployment-runbook.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Page on rising values for:
5656

5757
| Metric | Why it matters | First response |
5858
| --- | --- | --- |
59-
| `sentry_overload_degraded_total` | Escalations fell through to the fail mode because the worker queue was full. | Increase workers or queue, reduce escalation volume, tune the slow tier, or choose fail-closed deliberately. |
59+
| `sentry_overload_degraded_total` | Escalations were rejected by the full worker queue. Complete evidence uses the fail mode; incomplete command evidence remains unresolved. | Increase workers or queue, reduce escalation volume, tune the slow tier, or choose fail-closed deliberately for complete-evidence overflow. |
6060
| `sentry_enforce_failed_total` | A block wanted to write a deny file and failed. | Check volume space, mount mode, file permissions, and configured paths. |
6161

6262
Use `sentry_events_total` and `sentry_blocked_total` for traffic and block-ratio trends. `/healthz` only says the daemon is alive; it does not prove that every deny landed.
@@ -73,7 +73,10 @@ Tune:
7373
- `A3S_SENTRY_AGENT_TIMEOUT` for the L3 A3S Code investigation.
7474
- `A3S_SENTRY_SPECULATE` for high-severity events where parallel L2/L3 is worth the extra cost.
7575

76-
If overload rises, the deployment is under-provisioned for the current event mix or the deeper tier is too slow for the escalation rate.
76+
If overload rises, the deployment is under-provisioned for the current event
77+
mix or the deeper tier is too slow for the escalation rate. Complete-evidence
78+
events resolve through the fail mode; incomplete `ToolExec` evidence remains an
79+
audited L1 escalation.
7780

7881
## L2 Or L3 Outage
7982

@@ -97,5 +100,6 @@ Observer guards can continue enforcing existing deny files while Sentry restarts
97100

98101
- Observer-event Sentry is reactive. It can block the next matching action, not necessarily the action that produced the event.
99102
- Inline Gateway inspection is the pre-forward path for LLM/MCP traffic that is routed through the proxy.
103+
- The bundled daemon audits incomplete-evidence escalations but does not provide a durable external L3 queue; staged SDK consumers must own persistence and dispatch.
100104
- Denies are coarse and node-local: an IP or executable-path block can affect other workloads on the same node.
101105
- L2 and L3 process attacker-influenced content. Keep deterministic L1 and kernel guard enforcement as the floor.

apps/docs/content/docs/en/sentry/operations.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ most important counters to alert on are:
2929

3030
| Metric | Meaning |
3131
| --- | --- |
32-
| `sentry_overload_degraded_total` | An escalation could not be processed and fell through to the configured fail mode. |
32+
| `sentry_overload_degraded_total` | An escalation was rejected by the full worker queue. Complete evidence uses the fail mode; incomplete command evidence remains unresolved. |
3333
| `sentry_enforce_failed_total` | A decision wanted to enforce, but writing the deny record failed. |
3434
| `sentry_blocked_total` | Blocks by tier and event family. |
3535
| `sentry_events_total` | Total events judged. |
3636

37-
In fail-open deployments, overload degradation or enforce failure means a block
38-
may not have landed.
37+
Any non-zero overload rate means the worker pool is under-provisioned. In
38+
fail-open deployments, a complete-evidence overflow or enforce failure means a
39+
block may not have landed.
3940

4041
## Queue And Timeout Tuning
4142

@@ -47,10 +48,17 @@ L2 and L3 run in worker pools away from the ingest thread. Tune:
4748
- L3 timeout for deeper A3S Code investigation.
4849
- Speculation threshold when high-severity events deserve L2/L3 in parallel.
4950

51+
Complete-evidence queue overflow resolves through the configured fail mode.
52+
Incomplete `ToolExec` evidence remains an audited L1 escalation, even during
53+
overload.
54+
5055
## Boundaries
5156

5257
- Observer-event Sentry is reactive; it may block the next action rather than the
5358
action that produced the event.
59+
- The bundled daemon audits incomplete-evidence escalations but does not provide
60+
a durable external L3 queue. A staged SDK consumer must persist and dispatch
61+
them when deeper work is required.
5462
- Denies can be coarse: binary path and IP-based enforcement may affect more
5563
than one process on the same node.
5664
- L2/L3 read attacker-influenced content. The deterministic L1 floor and

apps/docs/content/docs/en/sentry/pipeline.mdx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Pipeline
3-
description: L1 rules, L2 LLM, L3 A3S Code investigation, SAE signals, fail posture, and speculative parallelism.
3+
description: L1 rules, L2 LLM, staged L3 dispatch, incomplete-evidence safeguards, SAE signals, fail posture, and speculation.
44
---
55

66
# Sentry Pipeline
@@ -38,6 +38,12 @@ rules can be provided through an ACL policy file and are hot-reloaded.
3838
L1 is a fast triage layer, not a sandbox. It is intentionally conservative: if a
3939
case is ambiguous, it escalates rather than guessing.
4040

41+
For `ToolExec`, Observer reports `argv_truncated` and `argv_incomplete` when it
42+
could not capture the complete command. A dangerous captured prefix can still
43+
block, but an otherwise ambiguous incomplete command remains an L1 escalation.
44+
The in-process L2/L3 judges are not asked to infer that a missing suffix was
45+
benign.
46+
4147
## L2 And L3
4248

4349
L2 is a classifier over the event. It is useful for false-positive reduction and
@@ -47,6 +53,13 @@ L3 is an actual A3S Code agent. It loads security skills, considers the actor,
4753
the observed event, the possible attack chain, and the blast radius, then
4854
returns a structured verdict. It is slower but deeper.
4955

56+
Products that separate fast judgment from deep investigation can call
57+
`Pipeline::evaluate_through_l2`. It returns the L1 decision, optional L2
58+
decision, effective decision, stage status, and escalation cause without
59+
invoking L3, applying `fail_closed`, or starting speculative L3. An
60+
`Escalated` result is work to persist and dispatch to a durable external L3
61+
worker, not an allow.
62+
5063
## Speculation
5164

5265
By default, L3 starts only after L2 escalates. With speculative parallelism,
@@ -61,4 +74,6 @@ fail-closed only when the deployment has enough L2/L3 capacity or an allow-list
6174
posture that can tolerate blocking unknowns.
6275

6376
Rules-only fail-open mode catches direct `block` rules but does not enforce
64-
rules that only escalate.
77+
rules that only escalate. Incomplete `ToolExec` evidence is the exception: it
78+
remains an unresolved L1 escalation regardless of fail mode. The bundled daemon
79+
audits that result but does not provide a durable external L3 queue.

0 commit comments

Comments
 (0)