Repository navigation
Commit f2c46ba
fix: Nickel strings stay literal; a manifest lookup error is not an absent manifest (#303)
## Summary
This follows up the two CodeRabbit findings on #302, which landed after
#302 merged. I checked both against nickel 1.18.0 and Rust std before
fixing them.
### 1. Nickel string escaping (`src/report/formatter.rs`)
`nickel_escape_string` used JSON quoting, which is wrong for Nickel in
two ways:
| Input | Old output | `nickel export` result |
|---|---|---|
| `/tmp/%{true}` | `"/tmp/%{true}"` | `"/tmp/true"`: interpolated |
| `a\u{1f}b` | `"a\u001fb"` | `invalid escape sequence` |
| `a\u{8}b` | `"a\bb"` | `invalid escape sequence` |
The escaper now writes:
- `\%` for every `%` (Nickel reads it back as `%`);
- `\"`, `\\`, `\n`, `\r` and `\t`;
- `\u{XX}` for any other control character.
The manifest export (`src/a2ml`) and the assault-report writer share
this escaper, so both are fixed.
### 2. Manifest lookup (`src/a2ml/mod.rs`)
`Manifest::default_path` and `load_if_exists` used `Path::exists()`.
That turns every metadata error (a self-referential symlink, a
permission error) into `false`, so the CLI quietly fell back to the
defaults. Both now use `try_exists()`:
- only a definite absence gives the defaults;
- a path whose existence can't be determined is an error, which the
startup warning reports.
## Tests
- `nickel_strings_stay_literal`: five tricky strings make the round trip
through `nickel export` unchanged, and three exact-output assertions
pass.
- `load_if_exists_reports_a_symlink_loop_instead_of_defaulting` (unix):
a self-referential `0-AI-MANIFEST.deed` is an error, not the defaults.
## Checks run locally
- `cargo build`: 0 warnings. The `serde_json` import in `formatter.rs`
was unused after the rewrite and is gone.
- `cargo test`: 818 passed, 0 failed.
- `cargo test --features http`: 885 passed, 0 failed.
- `cargo clippy --locked --all-targets --features http,sarif,signing --
-D warnings`: clean.
- `cargo fmt --check`: exit 0.
- `git diff --summary`: no mode changes.
---
_Generated by [Claude
Code](https://claude.ai/code/session_0136P7ZoBy5xGnGDLk7wQ8jC)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent c5fc2c6 commit f2c46ba
3 files changed
Lines changed: 96 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
185 | | - | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
192 | 194 | | |
193 | | - | |
194 | | - | |
195 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
196 | 200 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
201 | 209 | | |
202 | 210 | | |
203 | 211 | | |
| |||
1804 | 1812 | | |
1805 | 1813 | | |
1806 | 1814 | | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
1807 | 1831 | | |
1808 | 1832 | | |
1809 | 1833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
496 | 495 | | |
497 | 496 | | |
498 | 497 | | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
499 | 506 | | |
500 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
501 | 523 | | |
502 | 524 | | |
503 | 525 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
284 | 323 | | |
285 | 324 | | |
286 | 325 | | |
| |||
0 commit comments