Skip to content

Commit cb17db5

Browse files
RoyLinRoyLin
authored andcommitted
docs: sync bounded ACL diagnostics
1 parent 1843904 commit cb17db5

8 files changed

Lines changed: 100 additions & 20 deletions

File tree

apps/docs/content/docs/cn/acl/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Rust crate 与 Node.js/TypeScript SDK,可以把 ACL 文本解析成 AST,也
1818
| 领域 | 当前能力 |
1919
| --- | --- |
2020
| 语法 | ACL attributes、带 label 的 blocks、nested blocks、lists、objects、strings、numbers、booleans、null、function calls、comments,以及 `=` / `:` assignments。 |
21-
| Lexer/parser | Bounded parsing、stable diagnostic codes、UTF-8 byte spans、comment skipping、string escapes、negative numbers 和 scientific notation。 |
21+
| Lexer/parser | Bounded parsing 和 multi-diagnostic collection、stable diagnostic codes、UTF-8 byte spans、comment skipping、string escapes、negative numbers 和 scientific notation。 |
2222
| 函数 | 支持把 `env(...)``concat(...)` 和自定义函数名表示为 first-class call values。 |
2323
| AST | `Document``Block`、typed values、builders、value constructors 和 `Value` accessors。 |
2424
| 生成 | Native ACL output、block-header labels、sorted attributes 和 objects、type-stable strings,以及 map generation。 |
@@ -29,8 +29,8 @@ Rust crate 与 Node.js/TypeScript SDK,可以把 ACL 文本解析成 AST,也
2929

3030
- [Syntax](/cn/docs/acl/syntax) 说明 blocks、attributes、values、calls、
3131
comments 和 parser boundaries。
32-
- [Rust API](/cn/docs/acl/rust-api) 覆盖 bounded parsing、diagnostics、canonical
33-
digests、generation、builders 和 AST value helpers。
32+
- [Rust API](/cn/docs/acl/rust-api) 覆盖 bounded parsing、multi-diagnostic
33+
collection、canonical digests、generation、builders 和 AST value helpers。
3434
- [Node SDK](/cn/docs/acl/node-sdk) 覆盖 JavaScript/TypeScript parser、
3535
native ACL generator、canonical APIs 和 builders。
3636
- [Generation And Boundaries](/cn/docs/acl/generation-boundaries) 说明 stable

apps/docs/content/docs/cn/acl/node-sdk.mdx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Node SDK
3-
description: "@a3s-lab/acl 的 JavaScript/TypeScript bounded parsing、native ACL generation、canonical digests 和 builders。"
3+
description: "@a3s-lab/acl 的 JavaScript/TypeScript bounded parsing、multi-diagnostics、native ACL generation、canonical digests 和 builders。"
44
---
55

66
# Node SDK
@@ -44,8 +44,9 @@ const generated = generate(new DocumentBuilder().block(provider).build());
4444
| API | 作用 |
4545
| --- | --- |
4646
| `parse(input, limits?)` | 使用默认或显式 resource limits,把 ACL text 解析成 `Document`|
47-
| `DEFAULT_PARSE_LIMITS` | Document bytes、nesting、collection items 和 token bytes 的 shared immutable defaults。 |
48-
| `ParseError``DIAGNOSTIC_CODES` | Stable codes、complete spans、UTF-8 byte offsets 和 redacted messages。 |
47+
| `collectDiagnostics(input, limits?)` | 在不构造 partial AST 的前提下收集 bounded diagnostics。 |
48+
| `DEFAULT_PARSE_LIMITS` | Document bytes、nesting、collection items、token bytes 和 diagnostic count 的 shared immutable defaults。 |
49+
| `ParseError``DIAGNOSTIC_CODES``DiagnosticReport` | Stable codes、complete spans、UTF-8 byte offsets、redacted messages 和明确的 truncation state。 |
4950
| `generate(doc)` | 生成 labels 位于 block headers 的 native ACL text。 |
5051
| `canonicalBytes(doc)``canonicalDigest(doc)` | 生成 stable cross-SDK bytes 和带 algorithm prefix 的 SHA-256 digest。 |
5152
| `CanonicalError` | 对 non-finite numbers、non-scalar strings 和 non-portable identifiers 返回不回显值的错误。 |
@@ -70,6 +71,7 @@ try {
7071
maxNestingDepth: 32,
7172
maxCollectionItems: 1_000,
7273
maxTokenBytes: 16 * 1024,
74+
maxDiagnostics: 20,
7375
});
7476
} catch (error) {
7577
if (error instanceof ParseError) {
@@ -81,6 +83,22 @@ try {
8183
Document 和 token sizes 使用 UTF-8 bytes。Diagnostic messages 只标识 token
8284
kinds,不包含 source token values 或 snippets。
8385

86+
Parse API 仍然是 fail-fast。CLI 和 editor integrations 可以使用 bounded
87+
budget 收集多个错误:
88+
89+
```typescript
90+
import {collectDiagnostics} from '@a3s-lab/acl';
91+
92+
const report = collectDiagnostics('first = ]\nsecond = ]', {
93+
maxDiagnostics: 20,
94+
});
95+
```
96+
97+
发生 syntax error 后,collection 会从下一 source line 继续。
98+
Resource-limit diagnostics 仍然是 fatal。Report 最多保存
99+
`maxDiagnostics` 个 errors,只有在继续观察到超出 budget 的 error 后才会把
100+
`truncated` 设为 true。
101+
84102
## Native And Canonical Output
85103

86104
`generate` 只有一个 native ACL output contract。Labels 保留在 block headers;

apps/docs/content/docs/cn/acl/rust-api.mdx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Rust API
3-
description: a3s-acl 的 Rust bounded parsing、diagnostics、canonical digests、native ACL generation、AST 和 builders。
3+
description: a3s-acl 的 Rust bounded parsing、multi-diagnostics、canonical digests、native ACL generation、AST 和 builders。
44
---
55

66
# Rust API
@@ -34,8 +34,9 @@ Public crate exports:
3434
| API | 作用 |
3535
| --- | --- |
3636
| `parse` / `parse_acl` | 把 ACL text 解析成 `Document`|
37-
| `parse_with_limits``ParseLimits` | 使用显式 document、nesting、collection 和 token limits 解析 untrusted input。 |
38-
| `DiagnosticCode``ParseError` | 返回 stable codes、UTF-8 byte spans 和 redacted messages。 |
37+
| `parse_with_limits``ParseLimits` | 使用显式 document、nesting、collection、token 和 diagnostic limits 解析 untrusted input。 |
38+
| `collect_diagnostics``collect_diagnostics_with_limits` | 在不构造 partial AST 的前提下收集 bounded diagnostics。 |
39+
| `DiagnosticCode``ParseError``DiagnosticReport` | 返回 stable codes、UTF-8 byte spans、redacted messages 和明确的 truncation state。 |
3940
| `generate` / `generate_acl` |`Document` 生成 ACL text。 |
4041
| `generate_from_map` |`HashMap<String, Value>` 生成 ACL text。 |
4142
| `canonical_bytes``canonical_digest` | 生成 stable cross-SDK bytes 和带 algorithm prefix 的 SHA-256 digest。 |
@@ -55,6 +56,7 @@ let document = parse_with_limits(
5556
max_nesting_depth: 32,
5657
max_collection_items: 1_000,
5758
max_token_bytes: 16 * 1024,
59+
max_diagnostics: 20,
5860
},
5961
)?;
6062
```
@@ -64,6 +66,26 @@ Document 和 token sizes 使用 UTF-8 bytes。`ParseError` 提供 stable
6466
compatibility `line` / `column` fields。Messages 只标识 token kinds,不包含
6567
source token values 或 snippets。
6668

69+
Parse APIs 仍然是 fail-fast。CLI 和 editor integrations 可以使用 bounded
70+
budget 收集多个错误:
71+
72+
```rust
73+
use a3s_acl::{collect_diagnostics_with_limits, ParseLimits};
74+
75+
let report = collect_diagnostics_with_limits(
76+
"first = ]\nsecond = ]",
77+
ParseLimits {
78+
max_diagnostics: 20,
79+
..ParseLimits::default()
80+
},
81+
);
82+
```
83+
84+
发生 syntax error 后,collection 会从下一 source line 继续。
85+
Resource-limit diagnostics 仍然是 fatal。Report 最多保存
86+
`max_diagnostics` 个 errors,只有在继续观察到超出 budget 的 error 后才会把
87+
`truncated` 设为 true。
88+
6789
## AST
6890

6991
| Type | Fields |

apps/docs/content/docs/en/acl/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ is `@a3s-lab/acl` `0.2.2`. The crate repository metadata points to
1818
| Area | Current capability |
1919
| --- | --- |
2020
| Syntax | ACL attributes, labeled blocks, nested blocks, lists, objects, strings, numbers, booleans, null, function calls, comments, and `=` / `:` assignments. |
21-
| Lexer/parser | Bounded parsing, stable diagnostic codes, UTF-8 byte spans, comment skipping, string escapes, negative numbers, and scientific notation. |
21+
| Lexer/parser | Bounded parsing and multi-diagnostic collection, stable diagnostic codes, UTF-8 byte spans, comment skipping, string escapes, negative numbers, and scientific notation. |
2222
| Functions | First-class call values such as `env(...)`, `concat(...)`, and custom function names. |
2323
| AST | `Document`, `Block`, typed values, builders, value constructors, and `Value` accessors. |
2424
| Generation | Native ACL output, block-header labels, sorted attributes and objects, type-stable strings, and map generation. |
@@ -29,8 +29,8 @@ is `@a3s-lab/acl` `0.2.2`. The crate repository metadata points to
2929

3030
- [Syntax](/docs/acl/syntax) documents blocks, attributes, values, calls,
3131
comments, and parser boundaries.
32-
- [Rust API](/docs/acl/rust-api) covers bounded parsing, diagnostics, canonical
33-
digests, generation, builders, and AST value helpers.
32+
- [Rust API](/docs/acl/rust-api) covers bounded parsing, multi-diagnostic
33+
collection, canonical digests, generation, builders, and AST value helpers.
3434
- [Node SDK](/docs/acl/node-sdk) covers the JavaScript/TypeScript parser,
3535
native ACL generator, canonical APIs, and builders.
3636
- [Generation And Boundaries](/docs/acl/generation-boundaries) explains stable

apps/docs/content/docs/en/acl/node-sdk.mdx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Node SDK
3-
description: JavaScript and TypeScript bounded parsing, native ACL generation, canonical digests, and builders in @a3s-lab/acl.
3+
description: JavaScript and TypeScript bounded parsing, multi-diagnostics, native ACL generation, canonical digests, and builders in @a3s-lab/acl.
44
---
55

66
# Node SDK
@@ -44,8 +44,9 @@ const generated = generate(new DocumentBuilder().block(provider).build());
4444
| API | Role |
4545
| --- | --- |
4646
| `parse(input, limits?)` | Parse ACL text into a `Document` with default or explicit resource limits. |
47-
| `DEFAULT_PARSE_LIMITS` | Shared immutable defaults for document bytes, nesting, collection items, and token bytes. |
48-
| `ParseError`, `DIAGNOSTIC_CODES` | Stable codes, complete spans, UTF-8 byte offsets, and redacted messages. |
47+
| `collectDiagnostics(input, limits?)` | Collect bounded diagnostics without constructing a partial AST. |
48+
| `DEFAULT_PARSE_LIMITS` | Shared immutable defaults for document bytes, nesting, collection items, token bytes, and diagnostic count. |
49+
| `ParseError`, `DIAGNOSTIC_CODES`, `DiagnosticReport` | Stable codes, complete spans, UTF-8 byte offsets, redacted messages, and explicit truncation state. |
4950
| `generate(doc)` | Generate native ACL text with labels in block headers. |
5051
| `canonicalBytes(doc)`, `canonicalDigest(doc)` | Produce stable cross-SDK bytes and an algorithm-prefixed SHA-256 digest. |
5152
| `CanonicalError` | Report non-finite numbers, non-scalar strings, and non-portable identifiers without echoing values. |
@@ -70,6 +71,7 @@ try {
7071
maxNestingDepth: 32,
7172
maxCollectionItems: 1_000,
7273
maxTokenBytes: 16 * 1024,
74+
maxDiagnostics: 20,
7375
});
7476
} catch (error) {
7577
if (error instanceof ParseError) {
@@ -81,6 +83,22 @@ try {
8183
Document and token sizes count UTF-8 bytes. Diagnostic messages identify token
8284
kinds but never include source token values or snippets.
8385

86+
The parse API remains fail-fast. CLI and editor integrations can collect
87+
multiple errors with a bounded budget:
88+
89+
```typescript
90+
import {collectDiagnostics} from '@a3s-lab/acl';
91+
92+
const report = collectDiagnostics('first = ]\nsecond = ]', {
93+
maxDiagnostics: 20,
94+
});
95+
```
96+
97+
After a syntax error, collection resumes at the next source line.
98+
Resource-limit diagnostics remain fatal. A report stores at most
99+
`maxDiagnostics` errors and sets `truncated` only after observing another error
100+
beyond that budget.
101+
84102
## Native And Canonical Output
85103

86104
`generate` has one native ACL output contract. Labels remain in block headers;

apps/docs/content/docs/en/acl/rust-api.mdx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Rust API
3-
description: Rust bounded parsing, diagnostics, canonical digests, native ACL generation, AST, and builders for a3s-acl.
3+
description: Rust bounded parsing, multi-diagnostics, canonical digests, native ACL generation, AST, and builders for a3s-acl.
44
---
55

66
# Rust API
@@ -34,8 +34,9 @@ The public crate exports:
3434
| API | Role |
3535
| --- | --- |
3636
| `parse` / `parse_acl` | Parse ACL text into a `Document`. |
37-
| `parse_with_limits`, `ParseLimits` | Parse untrusted input with explicit document, nesting, collection, and token limits. |
38-
| `DiagnosticCode`, `ParseError` | Return stable codes, UTF-8 byte spans, and redacted messages. |
37+
| `parse_with_limits`, `ParseLimits` | Parse untrusted input with explicit document, nesting, collection, token, and diagnostic limits. |
38+
| `collect_diagnostics`, `collect_diagnostics_with_limits` | Collect bounded diagnostics without constructing a partial AST. |
39+
| `DiagnosticCode`, `ParseError`, `DiagnosticReport` | Return stable codes, UTF-8 byte spans, redacted messages, and explicit truncation state. |
3940
| `generate` / `generate_acl` | Generate ACL text from a `Document`. |
4041
| `generate_from_map` | Build ACL text from a `HashMap<String, Value>`. |
4142
| `canonical_bytes`, `canonical_digest` | Produce stable cross-SDK bytes and an algorithm-prefixed SHA-256 digest. |
@@ -55,6 +56,7 @@ let document = parse_with_limits(
5556
max_nesting_depth: 32,
5657
max_collection_items: 1_000,
5758
max_token_bytes: 16 * 1024,
59+
max_diagnostics: 20,
5860
},
5961
)?;
6062
```
@@ -64,6 +66,26 @@ Document and token sizes count UTF-8 bytes. `ParseError` exposes a stable
6466
compatibility `line` / `column` fields. Messages identify token kinds without
6567
including source token values or snippets.
6668

69+
The parse APIs remain fail-fast. CLI and editor integrations can collect
70+
multiple errors with a bounded budget:
71+
72+
```rust
73+
use a3s_acl::{collect_diagnostics_with_limits, ParseLimits};
74+
75+
let report = collect_diagnostics_with_limits(
76+
"first = ]\nsecond = ]",
77+
ParseLimits {
78+
max_diagnostics: 20,
79+
..ParseLimits::default()
80+
},
81+
);
82+
```
83+
84+
After a syntax error, collection resumes at the next source line.
85+
Resource-limit diagnostics remain fatal. A report stores at most
86+
`max_diagnostics` errors and sets `truncated` only after observing another
87+
error beyond that budget.
88+
6789
## AST
6890

6991
| Type | Fields |

compat/cloud-stack.acl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ component "acl" {
99
package = "a3s-acl"
1010
path = "crates/acl"
1111
repository = "git@github.com:A3S-Lab/ACL.git"
12-
revision = "9e55b23f3659cea390fe51d911c53a26a6902ac5"
12+
revision = "cef613ef945cff9ebbc5a36b983d1daaa1067fdb"
1313
source = "git"
1414
version = "0.2.2"
1515
}

0 commit comments

Comments
 (0)