@aid-framework/cli 0.1.61 → 0.1.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,55 @@
1
+ /**
2
+ * `aid guard` -- measure an app's guardrails against a red-team corpus.
3
+ *
4
+ * **What is measured, and why it is measured here.** The runtime's `GuardrailEngine` is
5
+ * the thing that decides whether text is a jailbreak, a secret, or an injection, and the
6
+ * generated `generated/guardrails.py` is the table of declarations the routes enforce.
7
+ * This command joins the two and reports, per fixture, whether the table the app actually
8
+ * shipped caught it. Detection is not reimplemented: a second implementation here would
9
+ * drift from the one the routes run, and the number it produced would describe the CLI
10
+ * rather than the application.
11
+ *
12
+ * **Why the corpus is an input.** The framework's own corpus lives in
13
+ * `runtimes/python/tests/redteam/fixtures.json` and is not shipped with any package.
14
+ * Copying it into the CLI would create a second copy that drifts from the one
15
+ * `test_redteam.py` gates on, and shipping it with the runtime would change a landed
16
+ * layer's published contents for one command's convenience. So the format is the
17
+ * contract: `--red-team` names a file, and without it the command looks for
18
+ * `redteam.json` beside the spec and then at the project root.
19
+ *
20
+ * **Why it evaluates the declared table, not one synthesized definition per fixture.**
21
+ * `test_redteam.py` builds a `GuardrailDefinition` for each fixture and runs it alone,
22
+ * because it is testing the detectors. This command is answering a different question --
23
+ * "would *this app* have caught this?" -- so it hands the engine every declaration that
24
+ * covers the fixture's stage, exactly as a route does, and a fixture counts as caught
25
+ * when any of them fires. A declaration that names the wrong policy still counts as a
26
+ * catch if its other policy fires: the app stopped the payload, which is what matters.
27
+ *
28
+ * **Why `covered` is a separate fact from `caught`.** "No declaration at this stage names
29
+ * this policy" is a spec gap the developer can close by editing the YAML; "declared but
30
+ * the detector missed" is a detector gap they cannot. Folding both into one recall number
31
+ * would send a reader to the wrong file, so the undeclared pairs are listed on their own
32
+ * line and in the `--json` document.
33
+ *
34
+ * **Why nothing is regenerated.** A gate measures the tree it is given, and `aid eval`
35
+ * already sets that precedent: this command reads `generated/guardrails.py`, and a tree
36
+ * that predates the spec is reported as a missing or stale module rather than silently
37
+ * replaced. Run `aid gen` first, as CI does.
38
+ *
39
+ * **When it does not run, and what it exits with.** Exit 2 is "this command could not
40
+ * judge the project": an unknown target, a target with no driver, a corpus that is
41
+ * missing or malformed, or no interpreter that can import the runtime. Exit 1 is a
42
+ * verdict about the project: it declares no guardrails, its tree has no guardrail module,
43
+ * the run failed, or the measured recall / false-positive rate misses what the corpus
44
+ * asks for.
45
+ */
46
+ import type { CliContext } from '../context.js';
47
+ import type { CommandOutcome } from '../output.js';
48
+ export interface GuardOptions {
49
+ readonly spec: string | undefined;
50
+ readonly target: string | undefined;
51
+ /** The corpus to measure against; discovered beside the spec when omitted. */
52
+ readonly redTeam: string | undefined;
53
+ }
54
+ export declare function guard(context: CliContext, options: GuardOptions): CommandOutcome;
55
+ //# sourceMappingURL=guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/commands/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAOnD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAwZD,wBAAgB,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,cAAc,CAkYhF"}