@intentius/chant-lexicon-cedar 0.44.8 → 0.44.10
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.
- package/README.md +106 -2
- package/dist/agentcore/embed.d.ts +189 -0
- package/dist/agentcore/embed.d.ts.map +1 -0
- package/dist/agentcore/enforcement.d.ts +76 -0
- package/dist/agentcore/enforcement.d.ts.map +1 -0
- package/dist/agentcore/scan.d.ts +46 -0
- package/dist/agentcore/scan.d.ts.map +1 -0
- package/dist/codegen/docs-dogwood.d.ts +21 -0
- package/dist/codegen/docs-dogwood.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/package.d.ts.map +1 -1
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/dogwood/cli.d.ts +247 -0
- package/dist/dogwood/cli.d.ts.map +1 -0
- package/dist/dogwood/event-schema.d.ts +161 -0
- package/dist/dogwood/event-schema.d.ts.map +1 -0
- package/dist/dogwood/index.d.ts +39 -0
- package/dist/dogwood/index.d.ts.map +1 -0
- package/dist/dogwood/macros.d.ts +96 -0
- package/dist/dogwood/macros.d.ts.map +1 -0
- package/dist/dogwood/policy.d.ts +120 -0
- package/dist/dogwood/policy.d.ts.map +1 -0
- package/dist/dogwood/replay-activity.d.ts +196 -0
- package/dist/dogwood/replay-activity.d.ts.map +1 -0
- package/dist/dogwood/replay-op.d.ts +165 -0
- package/dist/dogwood/replay-op.d.ts.map +1 -0
- package/dist/dogwood/scan.d.ts +109 -0
- package/dist/dogwood/scan.d.ts.map +1 -0
- package/dist/dogwood/serialize.d.ts +66 -0
- package/dist/dogwood/serialize.d.ts.map +1 -0
- package/dist/dogwood/temporal.d.ts +259 -0
- package/dist/dogwood/temporal.d.ts.map +1 -0
- package/dist/dogwood/trace.d.ts +215 -0
- package/dist/dogwood/trace.d.ts.map +1 -0
- package/dist/dogwood/upstream.d.ts +41 -0
- package/dist/dogwood/upstream.d.ts.map +1 -0
- package/dist/dogwood/window.d.ts +73 -0
- package/dist/dogwood/window.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +15 -3
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/post-synth/dogwood-helpers.d.ts +63 -0
- package/dist/lint/post-synth/dogwood-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc010.d.ts +25 -0
- package/dist/lint/post-synth/dwdc010.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc011.d.ts +19 -0
- package/dist/lint/post-synth/dwdc011.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc012.d.ts +21 -0
- package/dist/lint/post-synth/dwdc012.d.ts.map +1 -0
- package/dist/lint/post-synth/dwdc013.d.ts +33 -0
- package/dist/lint/post-synth/dwdc013.d.ts.map +1 -0
- package/dist/lint/post-synth/dwde010.d.ts +32 -0
- package/dist/lint/post-synth/dwde010.d.ts.map +1 -0
- package/dist/lint/post-synth/dwde011.d.ts +33 -0
- package/dist/lint/post-synth/dwde011.d.ts.map +1 -0
- package/dist/lint/post-synth/dwds010.d.ts +24 -0
- package/dist/lint/post-synth/dwds010.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/okf/index.md +7 -0
- package/dist/okf/rules/DWDC010.md +11 -0
- package/dist/okf/rules/DWDC011.md +11 -0
- package/dist/okf/rules/DWDC012.md +11 -0
- package/dist/okf/rules/DWDC013.md +15 -0
- package/dist/okf/rules/DWDE010.md +11 -0
- package/dist/okf/rules/DWDE011.md +11 -0
- package/dist/okf/rules/DWDS010.md +11 -0
- package/dist/okf/types/Policy.md +1 -0
- package/dist/op/activities/index.d.ts +18 -0
- package/dist/op/activities/index.d.ts.map +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/policy-text.d.ts +53 -0
- package/dist/policy-text.d.ts.map +1 -0
- package/dist/rules/dogwood-helpers.ts +139 -0
- package/dist/rules/dwdc010.ts +62 -0
- package/dist/rules/dwdc011.ts +61 -0
- package/dist/rules/dwdc012.ts +46 -0
- package/dist/rules/dwdc013.ts +64 -0
- package/dist/rules/dwde010.ts +130 -0
- package/dist/rules/dwde011.ts +108 -0
- package/dist/rules/dwds010.ts +46 -0
- package/dist/serializer.d.ts +10 -18
- package/dist/serializer.d.ts.map +1 -1
- package/dist/skills/chant-cedar-authoring.md +180 -0
- package/dist/skills/chant-cedar-avp-embedding.md +125 -0
- package/dist/skills/chant-cedar-dogwood.md +327 -0
- package/dist/skills/chant-cedar-meta-policy.md +119 -0
- package/package.json +7 -2
- package/src/agentcore/embed.test.ts +254 -0
- package/src/agentcore/embed.ts +399 -0
- package/src/agentcore/enforcement.test.ts +43 -0
- package/src/agentcore/enforcement.ts +92 -0
- package/src/agentcore/scan.ts +119 -0
- package/src/codegen/docs-dogwood.ts +1119 -0
- package/src/codegen/docs.ts +66 -1
- package/src/codegen/package.ts +3 -2
- package/src/config.test.ts +12 -0
- package/src/config.ts +28 -0
- package/src/dogwood/cli.test.ts +513 -0
- package/src/dogwood/cli.ts +666 -0
- package/src/dogwood/event-schema.test.ts +218 -0
- package/src/dogwood/event-schema.ts +318 -0
- package/src/dogwood/index.ts +271 -0
- package/src/dogwood/macros.test.ts +104 -0
- package/src/dogwood/macros.ts +229 -0
- package/src/dogwood/policy.test.ts +94 -0
- package/src/dogwood/policy.ts +141 -0
- package/src/dogwood/replay-activity.test.ts +481 -0
- package/src/dogwood/replay-activity.ts +506 -0
- package/src/dogwood/replay-op.ts +242 -0
- package/src/dogwood/scan.ts +287 -0
- package/src/dogwood/serialize.test.ts +331 -0
- package/src/dogwood/serialize.ts +246 -0
- package/src/dogwood/temporal.test.ts +272 -0
- package/src/dogwood/temporal.ts +592 -0
- package/src/dogwood/testdata/custom-kinds.dwschema +17 -0
- package/src/dogwood/testdata/default-macros.dw +23 -0
- package/src/dogwood/testdata/lowered-read-after-login.json +13 -0
- package/src/dogwood/testdata/max-window-raised.dwschema +25 -0
- package/src/dogwood/testdata/pinned.dwschema +31 -0
- package/src/dogwood/testdata/read-after-login.cedarschema +20 -0
- package/src/dogwood/testdata/read-after-login.dw +17 -0
- package/src/dogwood/testdata/temporal-policies.dw +53 -0
- package/src/dogwood/trace.test.ts +231 -0
- package/src/dogwood/trace.ts +471 -0
- package/src/dogwood/upstream.ts +41 -0
- package/src/dogwood/window.ts +124 -0
- package/src/index.ts +76 -0
- package/src/lint/audit-catalog.ts +64 -0
- package/src/lint/post-synth/dogwood-helpers.ts +139 -0
- package/src/lint/post-synth/dwd-post-synth.test.ts +374 -0
- package/src/lint/post-synth/dwdc010.ts +62 -0
- package/src/lint/post-synth/dwdc011.ts +61 -0
- package/src/lint/post-synth/dwdc012.ts +46 -0
- package/src/lint/post-synth/dwdc013.ts +64 -0
- package/src/lint/post-synth/dwde-post-synth.test.ts +368 -0
- package/src/lint/post-synth/dwde010.ts +130 -0
- package/src/lint/post-synth/dwde011.ts +108 -0
- package/src/lint/post-synth/dwds010.ts +46 -0
- package/src/lint/post-synth/index.ts +14 -0
- package/src/lint/post-synth/post-synth.test.ts +7 -3
- package/src/op/activities/index.ts +27 -0
- package/src/plugin.test.ts +3 -2
- package/src/plugin.ts +30 -0
- package/src/policy-text.ts +128 -0
- package/src/serializer.ts +71 -109
- package/src/skills/chant-cedar-dogwood.md +327 -0
package/dist/config.d.ts
CHANGED
|
@@ -69,6 +69,31 @@ export declare const cedarConfigSchema: z.ZodObject<{
|
|
|
69
69
|
*/
|
|
70
70
|
requireProjectSchema: z.ZodOptional<z.ZodBoolean>;
|
|
71
71
|
}, z.core.$strict>>;
|
|
72
|
+
/**
|
|
73
|
+
* The dogwood dialect's CLI-gated leg (#1659).
|
|
74
|
+
*
|
|
75
|
+
* `strictObject` again, for the reason the outer one is: a typo here is the
|
|
76
|
+
* difference between "full .dw validation ran" and "DWDE010 said it could
|
|
77
|
+
* not run", and the second is easy to skim past.
|
|
78
|
+
*/
|
|
79
|
+
dogwood: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
/**
|
|
81
|
+
* Path to the `dogwood` binary, absolute or relative to the config file.
|
|
82
|
+
*
|
|
83
|
+
* Optional, and its absence is not an error: DWDE010 warns-and-skips
|
|
84
|
+
* with an issue-linked advisory when no binary is found, which is the
|
|
85
|
+
* epic's explicit exception. Set this when the binary is built somewhere
|
|
86
|
+
* `PATH` does not reach — the on-demand harness shape the epic borrows
|
|
87
|
+
* from forgejo-runtime-e2e.
|
|
88
|
+
*
|
|
89
|
+
* A `chant.config.ts` cannot be read from inside a post-synth check —
|
|
90
|
+
* `check()` is synchronous and evaluating project code is not — so this
|
|
91
|
+
* key is honoured from `chant.config.json` and the `CHANT_DOGWOOD_BINARY`
|
|
92
|
+
* environment variable covers the TypeScript-config case. See
|
|
93
|
+
* `src/dogwood/cli.ts`.
|
|
94
|
+
*/
|
|
95
|
+
binary: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strict>>;
|
|
72
97
|
}, z.core.$strict>;
|
|
73
98
|
export type CedarConfig = z.infer<typeof cedarConfigSchema>;
|
|
74
99
|
declare module "@intentius/chant/config" {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;;;;;OAMG;;IAGH;;;;OAIG;;QAGC,0EAA0E;;QAE1E;;;WAGG;;;;;;QAEH;;;;;;WAMG;;;kBAIP,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,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
|
1
|
+
/**
|
|
2
|
+
* The `dogwood` CLI adapter (#1659, epic #1646).
|
|
3
|
+
*
|
|
4
|
+
* The epic splits validation by what needs a binary. Everything answerable in
|
|
5
|
+
* TypeScript — the DWDC walls in `../lint/post-synth/dwdc0*.ts` — runs always
|
|
6
|
+
* and gates. Full `.dw` validation needs upstream's own frontend, which ships
|
|
7
|
+
* only as a Rust CLI: no npm package, no wasm build, nothing to link against.
|
|
8
|
+
* This module is the seam to it, and everything downstream of it treats the
|
|
9
|
+
* binary as optional.
|
|
10
|
+
*
|
|
11
|
+
* Five things about that CLI decide how this is written, all from the #1657
|
|
12
|
+
* verification report and re-read from the pinned `dogwood-cli/src` sources:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Exit codes do not identify the failure.** Exit 2 is both "the policy
|
|
15
|
+
* set was rejected" and clap's own usage error for an unknown flag, and the
|
|
16
|
+
* published guide claims 1 for the latter. So nothing here branches on the
|
|
17
|
+
* exit code: the JSON on stdout decides, and a run that produced no JSON is
|
|
18
|
+
* {@link DogwoodUnusable} — reported as "the CLI could not be used", never
|
|
19
|
+
* as "your policy is bad".
|
|
20
|
+
* 2. **There are two JSON shapes, not one.** A type-check finding comes back
|
|
21
|
+
* in a `ValidateReport` (`{passed, passed_without_warnings, errors[],
|
|
22
|
+
* warnings[]}`); a fatal parse, macro or lowering error replaces the whole
|
|
23
|
+
* report with a bare `OpError` — the same diagnostic fields flattened at the
|
|
24
|
+
* top level, plus `related[]`. {@link parseValidateOutput} handles both.
|
|
25
|
+
* 3. **`--format json` writes to stdout for both channels**, success and
|
|
26
|
+
* fatal alike, and human-mode errors go to stderr. Every call here passes
|
|
27
|
+
* `--format json` and reads stdout; stderr is kept only to explain an
|
|
28
|
+
* unusable run.
|
|
29
|
+
* 4. **`--emit` is ignored under `--format json`** — the JSON always carries
|
|
30
|
+
* all three lowered artifacts — so {@link runDogwoodLower} does not pass it.
|
|
31
|
+
* 5. **Label offsets are bytes into the source**, not line/column. They are
|
|
32
|
+
* rendered as byte ranges. The fatal channel's own internal positions are
|
|
33
|
+
* never passed through verbatim, for the same reason `wasm-helpers.ts`
|
|
34
|
+
* strips cedar-wasm's `at line 1 column 42`: they locate something in a
|
|
35
|
+
* representation the reader never saw.
|
|
36
|
+
*
|
|
37
|
+
* The runner is injectable ({@link configureDogwoodCli}) so the checks are
|
|
38
|
+
* testable without the binary. Nothing in gating CI executes it.
|
|
39
|
+
*/
|
|
40
|
+
/** The executable name looked up on `PATH`. */
|
|
41
|
+
export declare const DOGWOOD_BINARY_NAME = "dogwood";
|
|
42
|
+
/** Environment override, read before `PATH` and after an explicit config. */
|
|
43
|
+
export declare const DOGWOOD_BINARY_ENV = "CHANT_DOGWOOD_BINARY";
|
|
44
|
+
/** Where a resolved binary came from — carried so a finding can say. */
|
|
45
|
+
export type DogwoodBinarySource = "override" | "env" | "config" | "path";
|
|
46
|
+
/** A located `dogwood` executable. */
|
|
47
|
+
export interface DogwoodBinary {
|
|
48
|
+
/** Absolute path, or the configured path as written. */
|
|
49
|
+
path: string;
|
|
50
|
+
source: DogwoodBinarySource;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* One process run, reduced to what the adapter reads.
|
|
54
|
+
*
|
|
55
|
+
* `error` is set when the process never ran at all (ENOENT, a permission
|
|
56
|
+
* failure, a timeout) — distinct from a run that exited non-zero.
|
|
57
|
+
*/
|
|
58
|
+
export interface DogwoodRun {
|
|
59
|
+
status: number | null;
|
|
60
|
+
stdout: string;
|
|
61
|
+
stderr: string;
|
|
62
|
+
error?: string;
|
|
63
|
+
}
|
|
64
|
+
/** Runs `binary args…` and returns the captured streams. Injectable for tests. */
|
|
65
|
+
export type DogwoodRunner = (binary: string, args: string[]) => DogwoodRun;
|
|
66
|
+
interface CliDefaults {
|
|
67
|
+
/** A path forces that binary; `null` forces "absent"; `undefined` resolves normally. */
|
|
68
|
+
binary?: string | null;
|
|
69
|
+
runner?: DogwoodRunner;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Override binary resolution and the process runner.
|
|
73
|
+
*
|
|
74
|
+
* Two callers. Tests inject a runner so no gating check ever depends on a real
|
|
75
|
+
* binary — including on a developer's machine that happens to have one, which
|
|
76
|
+
* is why `binary: null` (force-absent) exists as well as `binary: "/path"`.
|
|
77
|
+
* The on-demand harness — the `forgejo-runtime-e2e` shape the epic names — is
|
|
78
|
+
* the other: it knows where it built the binary and says so directly rather
|
|
79
|
+
* than arranging `PATH`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function configureDogwoodCli(options: CliDefaults): void;
|
|
82
|
+
/** Drop every override, including any cached resolution. Test-only. */
|
|
83
|
+
export declare function resetDogwoodCli(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Locate the `dogwood` binary, or `undefined` when there is none.
|
|
86
|
+
*
|
|
87
|
+
* Order: an explicit {@link configureDogwoodCli} override, `$CHANT_DOGWOOD_BINARY`,
|
|
88
|
+
* `cedar.dogwood.binary` from a `chant.config.json`, then `PATH`. A path from
|
|
89
|
+
* the environment or the config that is not executable is resolved past rather
|
|
90
|
+
* than returned to fail later; the advisory that follows names where chant
|
|
91
|
+
* looked. An explicit override is taken as given — its caller knows.
|
|
92
|
+
*/
|
|
93
|
+
export declare function findDogwoodBinary(cwd?: string): DogwoodBinary | undefined;
|
|
94
|
+
/** Where chant looked, for an advisory that has to be actionable. */
|
|
95
|
+
export declare const DOGWOOD_SEARCH_ORDER = "$CHANT_DOGWOOD_BINARY, then cedar.dogwood.binary in chant.config.json, then `dogwood` on PATH";
|
|
96
|
+
/** One labelled span: byte offsets into the source the CLI was handed. */
|
|
97
|
+
export interface DogwoodLabel {
|
|
98
|
+
start: number;
|
|
99
|
+
len: number;
|
|
100
|
+
message?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* One diagnostic, in upstream's `Diagnostic` shape.
|
|
104
|
+
*
|
|
105
|
+
* The same object is the element type of a report's `errors[]`/`warnings[]`
|
|
106
|
+
* and the whole body of a fatal `OpError`, which is why both channels
|
|
107
|
+
* normalize into this and nothing downstream has to know which arrived.
|
|
108
|
+
*/
|
|
109
|
+
export interface DogwoodDiagnostic {
|
|
110
|
+
/** `error`, `warning` or `advice` — upstream lowercases miette's severity. */
|
|
111
|
+
severity: string;
|
|
112
|
+
/** A stable code such as `extension` or `cedar`, when the finding has one. */
|
|
113
|
+
code?: string;
|
|
114
|
+
message: string;
|
|
115
|
+
labels: DogwoodLabel[];
|
|
116
|
+
help?: string;
|
|
117
|
+
/** False when the finding has no source-anchored span at all. */
|
|
118
|
+
spanned: boolean;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* One diagnostic as a single line: code, message, help, then the byte ranges.
|
|
122
|
+
*
|
|
123
|
+
* Byte offsets rather than line/column because that is what upstream reports
|
|
124
|
+
* and converting them would mean re-deriving line breaks over a file this
|
|
125
|
+
* module does not hold — a wrong line number is worse than an honest offset.
|
|
126
|
+
*/
|
|
127
|
+
export declare function formatDogwoodDiagnostic(diagnostic: DogwoodDiagnostic): string;
|
|
128
|
+
/**
|
|
129
|
+
* The CLI could not be used — a spawn failure, output that is not the JSON
|
|
130
|
+
* this adapter knows, or the exit-2 ambiguity resolving to neither shape.
|
|
131
|
+
*
|
|
132
|
+
* Deliberately its own arm and never folded into "rejected": exit 2 covers an
|
|
133
|
+
* unknown flag as well as a rejected policy set, so treating a bare non-zero
|
|
134
|
+
* exit as a policy verdict would fail a build over a flag rename in a sync
|
|
135
|
+
* upstream can make without notice.
|
|
136
|
+
*/
|
|
137
|
+
export interface DogwoodUnusable {
|
|
138
|
+
kind: "unusable";
|
|
139
|
+
reason: string;
|
|
140
|
+
}
|
|
141
|
+
/** A fatal parse, macro or lowering error — upstream's `OpError` channel. */
|
|
142
|
+
export interface DogwoodFatal {
|
|
143
|
+
kind: "fatal";
|
|
144
|
+
error: DogwoodDiagnostic;
|
|
145
|
+
related: DogwoodDiagnostic[];
|
|
146
|
+
}
|
|
147
|
+
export type DogwoodValidateResult = {
|
|
148
|
+
kind: "passed";
|
|
149
|
+
warnings: DogwoodDiagnostic[];
|
|
150
|
+
} | {
|
|
151
|
+
kind: "rejected";
|
|
152
|
+
errors: DogwoodDiagnostic[];
|
|
153
|
+
warnings: DogwoodDiagnostic[];
|
|
154
|
+
} | DogwoodFatal | DogwoodUnusable;
|
|
155
|
+
/** The `lower` artifacts. `cedarSchemaJson` is a JSON *string*, as upstream serializes it. */
|
|
156
|
+
export interface DogwoodLowered {
|
|
157
|
+
cedarPolicies: string;
|
|
158
|
+
cedarSchema: string;
|
|
159
|
+
cedarSchemaJson: string;
|
|
160
|
+
/** False when temporal or provider fields were hoisted — the usual case. */
|
|
161
|
+
selfContained: boolean;
|
|
162
|
+
temporalFields: string[];
|
|
163
|
+
providerFields: string[];
|
|
164
|
+
decisionKinds: string[];
|
|
165
|
+
}
|
|
166
|
+
export type DogwoodLowerResult = {
|
|
167
|
+
kind: "lowered";
|
|
168
|
+
value: DogwoodLowered;
|
|
169
|
+
} | DogwoodFatal | DogwoodUnusable;
|
|
170
|
+
/**
|
|
171
|
+
* One decision point out of `replay --format json`.
|
|
172
|
+
*
|
|
173
|
+
* `index` is the 0-based position in the *decision* stream, not the trace line
|
|
174
|
+
* number: a history-only event (any kind the event schema does not mark
|
|
175
|
+
* `decision`) contributes history and no verdict, so the two do not line up.
|
|
176
|
+
*/
|
|
177
|
+
export interface DogwoodVerdict {
|
|
178
|
+
index: number;
|
|
179
|
+
/** The `@<timestamp>` of the line that produced this decision. */
|
|
180
|
+
timestamp: number;
|
|
181
|
+
verdict: "allow" | "deny";
|
|
182
|
+
/** `.dw` rule indices that determined the decision — upstream's `[rules: 0, 2]`. */
|
|
183
|
+
determiningRules: number[];
|
|
184
|
+
/** Per-evaluation errors, such as a provider with no inlined Rhai script. */
|
|
185
|
+
errors: string[];
|
|
186
|
+
}
|
|
187
|
+
export type DogwoodReplayResult = {
|
|
188
|
+
kind: "replayed";
|
|
189
|
+
verdicts: DogwoodVerdict[];
|
|
190
|
+
} | DogwoodFatal | DogwoodUnusable;
|
|
191
|
+
/**
|
|
192
|
+
* Read a `validate --format json` run.
|
|
193
|
+
*
|
|
194
|
+
* The JSON decides, not the exit code. A body carrying `passed` is the report
|
|
195
|
+
* shape; a body carrying `message` and no `passed` is the fatal `OpError`
|
|
196
|
+
* shape; anything else means the invocation itself was rejected — which is
|
|
197
|
+
* where clap's exit-2 usage error lands, with its complaint on stderr and
|
|
198
|
+
* nothing on stdout.
|
|
199
|
+
*/
|
|
200
|
+
export declare function parseValidateOutput(run: DogwoodRun): DogwoodValidateResult;
|
|
201
|
+
/** Read a `lower --format json` run. Same two-shape discipline as validate. */
|
|
202
|
+
export declare function parseLowerOutput(run: DogwoodRun): DogwoodLowerResult;
|
|
203
|
+
/**
|
|
204
|
+
* Read a `replay --format json` run.
|
|
205
|
+
*
|
|
206
|
+
* The one place the exit-code discipline matters most: **replay exits 0 even
|
|
207
|
+
* when every verdict is DENY.** A nonzero exit means the trace or the policy
|
|
208
|
+
* set failed to load, never that a policy denied — so a caller that read the
|
|
209
|
+
* exit code as a verdict would report a working deny-by-default policy set as
|
|
210
|
+
* a broken one. As everywhere else in this module, the JSON decides: a body
|
|
211
|
+
* carrying `verdicts` is the report, a body carrying `message` is the fatal
|
|
212
|
+
* `OpError` (a malformed trace line lands here), anything else is unusable.
|
|
213
|
+
*/
|
|
214
|
+
export declare function parseReplayOutput(run: DogwoodRun): DogwoodReplayResult;
|
|
215
|
+
/**
|
|
216
|
+
* The files one CLI invocation needs.
|
|
217
|
+
*
|
|
218
|
+
* `policies` and `policySchema` are both required — every pipeline command
|
|
219
|
+
* takes the policy set positionally and `--policy-schema` is not optional. The
|
|
220
|
+
* rest are the service half of the schema, each defaulting at the far end.
|
|
221
|
+
*/
|
|
222
|
+
export interface DogwoodBundle {
|
|
223
|
+
/** `.dw` policy set text. */
|
|
224
|
+
policies: string;
|
|
225
|
+
/** Cedar action schema text (`--policy-schema`). */
|
|
226
|
+
policySchema: string;
|
|
227
|
+
/** `.dwschema` event-schema text (`--event-schema`). */
|
|
228
|
+
eventSchema?: string;
|
|
229
|
+
/** `.dw` macro library text (`--macros`). */
|
|
230
|
+
macros?: string;
|
|
231
|
+
/** `providers.json` text (`--providers`). Rhai must be inlined under `implementation.script`. */
|
|
232
|
+
providers?: string;
|
|
233
|
+
}
|
|
234
|
+
/** Run `dogwood validate` over a bundle. Never throws. */
|
|
235
|
+
export declare function runDogwoodValidate(binary: string, bundle: DogwoodBundle): DogwoodValidateResult;
|
|
236
|
+
/** Run `dogwood lower` over a bundle. Never throws. */
|
|
237
|
+
export declare function runDogwoodLower(binary: string, bundle: DogwoodBundle): DogwoodLowerResult;
|
|
238
|
+
/**
|
|
239
|
+
* Run `dogwood replay` over a bundle and a trace. Never throws.
|
|
240
|
+
*
|
|
241
|
+
* The trace is materialized beside the bundle's own files and passed as
|
|
242
|
+
* `--trace`; the same scratch directory is removed in the same `finally`, so a
|
|
243
|
+
* trace carrying a session's request payloads does not outlive the run.
|
|
244
|
+
*/
|
|
245
|
+
export declare function runDogwoodReplay(binary: string, bundle: DogwoodBundle, trace: string): DogwoodReplayResult;
|
|
246
|
+
export {};
|
|
247
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/dogwood/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AASH,+CAA+C;AAC/C,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AAEzD,wEAAwE;AACxE,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEzE,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,mBAA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M,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,GAChD,YAAY,GACZ,eAAe,CAAC;AAmBpB;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,GAAG,qBAAqB,CAuB1E;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CA6BpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,mBAAmB,CAkBtE;AAmDD;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+ED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,qBAAqB,CAM/F;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,kBAAkB,CAMzF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAQ1G"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed authoring for the `.dwschema` event-schema DSL.
|
|
3
|
+
*
|
|
4
|
+
* The `.dwschema`/`.cedarschema` question the epic flagged was a false alarm
|
|
5
|
+
* (#1657 §2): they are the two halves of one schema. The required half is the
|
|
6
|
+
* Cedar action schema (`--policy-schema`); this file is the optional half, the
|
|
7
|
+
* service side, which says what event *kinds* exist and what fields each one
|
|
8
|
+
* carries. Upstream's grammar is 136 lines of pest and is purely syntactic —
|
|
9
|
+
* it never consults an action schema, which is why every declaration is
|
|
10
|
+
* written against a symbolic action binder `<A>`:
|
|
11
|
+
*
|
|
12
|
+
* ```
|
|
13
|
+
* decision event <A>::request {
|
|
14
|
+
* ...inputs(A),
|
|
15
|
+
* pin callerPrincipal: principalType(A) = principal,
|
|
16
|
+
* callerResource: resourceType(A),
|
|
17
|
+
* requestId: String,
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* That symbolic binder is why DWDC010 can check an event *kind* against the
|
|
22
|
+
* emitted schema but not an action: the schema names no actions at all.
|
|
23
|
+
*
|
|
24
|
+
* ## The pin, and why opting out is explicit here
|
|
25
|
+
*
|
|
26
|
+
* `ServiceSchema::defaults()` — what runs when no `--event-schema` is passed —
|
|
27
|
+
* pins `callerPrincipal = principal` on every kind, so every temporal
|
|
28
|
+
* predicate is correlated to the current request's principal and events from
|
|
29
|
+
* other principals are invisible. Supplying *any* event schema opts out of the
|
|
30
|
+
* default wholesale, so a schema emitted without that pin silently widens
|
|
31
|
+
* every temporal predicate in the policy set to cross-principal.
|
|
32
|
+
*
|
|
33
|
+
* {@link defaultEventSchema} therefore carries the pin, and dropping it takes
|
|
34
|
+
* a named argument (`pinCallerPrincipal: false`) that also stamps a comment
|
|
35
|
+
* into the emitted file. DWDS010 reports the resulting schema either way, so
|
|
36
|
+
* the choice is visible in the build and not only in the source.
|
|
37
|
+
*/
|
|
38
|
+
import { type TemporalWindow, type WindowLike } from "./window.js";
|
|
39
|
+
/** The four selectors that read from the bound action. */
|
|
40
|
+
export type EventSelector = "inputs" | "outputs" | "principalType" | "resourceType";
|
|
41
|
+
/** `principalType(A)`, a nested `{ … }` record, or a concrete Cedar type. */
|
|
42
|
+
export type EventFieldType = {
|
|
43
|
+
readonly type: "selector";
|
|
44
|
+
readonly selector: EventSelector;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "record";
|
|
47
|
+
readonly fields: readonly EventField[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "concrete";
|
|
50
|
+
readonly name: string;
|
|
51
|
+
};
|
|
52
|
+
/** `principalType(A)` — the action's principal entity type. */
|
|
53
|
+
export declare function principalType(): EventFieldType;
|
|
54
|
+
/** `resourceType(A)` — the action's resource entity type. */
|
|
55
|
+
export declare function resourceType(): EventFieldType;
|
|
56
|
+
/** `String`, `Long`, `MyApp::OAuthUser` — a concrete (possibly qualified) type. */
|
|
57
|
+
export declare function concrete(name: string): EventFieldType;
|
|
58
|
+
/** `{ … }` — the named field becomes a group addressed as `name.member`. */
|
|
59
|
+
export declare function record(fields: EventField[]): EventFieldType;
|
|
60
|
+
/**
|
|
61
|
+
* The right-hand side of a pin: the request-side value the field is forced to
|
|
62
|
+
* match. `principal`/`resource` (with an optional attribute tail) or a
|
|
63
|
+
* `context.<path>`.
|
|
64
|
+
*/
|
|
65
|
+
export type PinTarget = {
|
|
66
|
+
readonly ref: "principal" | "resource";
|
|
67
|
+
readonly attrs: readonly string[];
|
|
68
|
+
} | {
|
|
69
|
+
readonly ref: "context";
|
|
70
|
+
readonly path: readonly string[];
|
|
71
|
+
};
|
|
72
|
+
/** `= principal`, or `= principal.dept`. */
|
|
73
|
+
export declare function pinPrincipal(...attrs: string[]): PinTarget;
|
|
74
|
+
/** `= resource`, or `= resource.owner`. */
|
|
75
|
+
export declare function pinResource(...attrs: string[]): PinTarget;
|
|
76
|
+
/** `= context.input.user`. At least one path segment; `context` alone is not a pin. */
|
|
77
|
+
export declare function pinContext(path: string): PinTarget;
|
|
78
|
+
/** `...inputs(A)` / `...outputs(A)` — splice every field the selector yields. */
|
|
79
|
+
export interface SpreadField {
|
|
80
|
+
readonly field: "spread";
|
|
81
|
+
readonly selector: Extract<EventSelector, "inputs" | "outputs">;
|
|
82
|
+
}
|
|
83
|
+
/** `[pin] name: <type> [= <pin target>]`. */
|
|
84
|
+
export interface NamedField {
|
|
85
|
+
readonly field: "named";
|
|
86
|
+
readonly name: string;
|
|
87
|
+
readonly type: EventFieldType;
|
|
88
|
+
readonly pin?: PinTarget;
|
|
89
|
+
}
|
|
90
|
+
/** One entry in an event declaration's field list. */
|
|
91
|
+
export type EventField = SpreadField | NamedField;
|
|
92
|
+
/** `...inputs(A)`. */
|
|
93
|
+
export declare function spreadInputs(): SpreadField;
|
|
94
|
+
/** `...outputs(A)`. */
|
|
95
|
+
export declare function spreadOutputs(): SpreadField;
|
|
96
|
+
/** `name: <type>` — an injected field with an explicit type. */
|
|
97
|
+
export declare function field(name: string, type: EventFieldType): NamedField;
|
|
98
|
+
/**
|
|
99
|
+
* `pin name: <type> = <target>` — a correlation against the decision request.
|
|
100
|
+
*
|
|
101
|
+
* Upstream requires the `pin` prefix and the `= …` clause together, and a
|
|
102
|
+
* pinned field must be a leaf (never a record type), so both are enforced here
|
|
103
|
+
* rather than deferred to the parser.
|
|
104
|
+
*/
|
|
105
|
+
export declare function pinnedField(name: string, type: EventFieldType, target: PinTarget): NamedField;
|
|
106
|
+
/** `[decision] event <A>::kind { fields }`. */
|
|
107
|
+
export interface EventDeclaration {
|
|
108
|
+
/** `request`, `response`, `error`, or anything the author chooses. */
|
|
109
|
+
readonly kind: string;
|
|
110
|
+
/** True for the kind that carries the authorization decision. */
|
|
111
|
+
readonly decision?: boolean;
|
|
112
|
+
readonly fields: readonly EventField[];
|
|
113
|
+
/** Emitted as `// …` above the declaration. */
|
|
114
|
+
readonly comment?: string;
|
|
115
|
+
}
|
|
116
|
+
/** One `event` declaration. */
|
|
117
|
+
export declare function eventDeclaration(kind: string, fields: EventField[], options?: {
|
|
118
|
+
decision?: boolean;
|
|
119
|
+
comment?: string;
|
|
120
|
+
}): EventDeclaration;
|
|
121
|
+
/** A whole `.dwschema` file. */
|
|
122
|
+
export interface EventSchema {
|
|
123
|
+
/** `max_window = 30d`. Omitted means upstream's 24h default applies. */
|
|
124
|
+
readonly maxWindow?: TemporalWindow;
|
|
125
|
+
/** The action binder name, `A` by convention. */
|
|
126
|
+
readonly binder: string;
|
|
127
|
+
readonly events: readonly EventDeclaration[];
|
|
128
|
+
/** Header comment lines, emitted above everything. */
|
|
129
|
+
readonly comment?: string;
|
|
130
|
+
}
|
|
131
|
+
/** Assemble a schema, defaulting the action binder to `A`. */
|
|
132
|
+
export declare function eventSchema(events: EventDeclaration[], options?: {
|
|
133
|
+
maxWindow?: WindowLike;
|
|
134
|
+
binder?: string;
|
|
135
|
+
comment?: string;
|
|
136
|
+
}): EventSchema;
|
|
137
|
+
/**
|
|
138
|
+
* The default event-schema shape: `request` (deciding), `response` and `error`,
|
|
139
|
+
* each pinned to the request's principal.
|
|
140
|
+
*
|
|
141
|
+
* This reproduces `configuration/event-schemas/pinned.dwschema`, which is what
|
|
142
|
+
* `ServiceSchema::defaults()` uses. Emitting it explicitly is the honest thing
|
|
143
|
+
* to do the moment a project supplies *any* event schema, because supplying
|
|
144
|
+
* one opts out of the built-in default entirely.
|
|
145
|
+
*
|
|
146
|
+
* @param options.pinCallerPrincipal Drop the pin to allow cross-principal
|
|
147
|
+
* correlation. A deliberate choice: it widens every temporal predicate in the
|
|
148
|
+
* policy set, so it stamps a comment into the emitted file and DWDS010 reports
|
|
149
|
+
* it in the build.
|
|
150
|
+
*/
|
|
151
|
+
export declare function defaultEventSchema(options?: {
|
|
152
|
+
maxWindow?: WindowLike;
|
|
153
|
+
pinCallerPrincipal?: boolean;
|
|
154
|
+
principalField?: string;
|
|
155
|
+
binder?: string;
|
|
156
|
+
}): EventSchema;
|
|
157
|
+
/** Render a schema to `.dwschema` text. */
|
|
158
|
+
export declare function renderEventSchema(schema: EventSchema): string;
|
|
159
|
+
/** Every event kind a schema declares, in declaration order. */
|
|
160
|
+
export declare function declaredEventKinds(schema: EventSchema): string[];
|
|
161
|
+
//# sourceMappingURL=event-schema.d.ts.map
|
|
@@ -0,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G,MAAM,EAAE,CAEhE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dogwood temporal dialect (#1658, epic #1646).
|
|
3
|
+
*
|
|
4
|
+
* A dialect of the cedar lexicon, not a lexicon of its own: `.dw` policies are
|
|
5
|
+
* Cedar policies with temporal clauses, their entity and action schemas are
|
|
6
|
+
* Cedar schemas, and the rendering is shared with the `.cedar` leg. Checks
|
|
7
|
+
* ship under the `DWD` id family, declared on the cedar serializer's
|
|
8
|
+
* `extraRulePrefixes`.
|
|
9
|
+
*
|
|
10
|
+
* Pre-release. Upstream (dogwood-policy/dogwood, Apache-2.0) is a read-only
|
|
11
|
+
* squash-sync mirror with no tags, no releases and no stability statement, and
|
|
12
|
+
* calls itself "NOT intended for production use". The surface here is built
|
|
13
|
+
* against the revision recorded in `./upstream.ts` and re-verified per
|
|
14
|
+
* sub-issue.
|
|
15
|
+
*/
|
|
16
|
+
export { DEFAULT_MAX_WINDOW, isWindowParam, renderWindow, renderWindowValue, window, windowParam, windowSeconds, windowValue, } from "./window.js";
|
|
17
|
+
export type { TemporalWindow, TimeUnit, WindowLike, WindowParam, WindowValue } from "./window.js";
|
|
18
|
+
export { and, arrayOf, binderName, bool, call, compare, count, ctx, decimalOf, entityUid, exists, formerly, int, interval, not, predicate, previous, raw, renderCondition, renderTerm, scopeRef, sigilCondition, since, str, sum, temporalMarker, term, tp, typedBinder, varRef, wildcard, } from "./temporal.js";
|
|
19
|
+
export type { AndNode, ArrayTerm, CallNode, ComparisonNode, ComparisonOperator, CountTerm, ExistsNode, FormerlyNode, IntervalArg, MacroArg, NotNode, PredicateNode, PreviousNode, RawCondition, SigilCondition, SinceNode, SumTerm, TemporalCondition, TemporalTerm, TermInput, TermText, TpNode, TypedBinder, WindowArgument, } from "./temporal.js";
|
|
20
|
+
export { DEFAULT_MACRO_NAMES, bind, countDistinctWithin, countWithin, defCedarMacro, defTemporalMacro, defaultMacroLibrary, macroCondition, macroTerm, macroWindow, renderMacroDefinition, renderMacroLibrary, sumWithin, } from "./macros.js";
|
|
21
|
+
export type { MacroDefinition, MacroKind } from "./macros.js";
|
|
22
|
+
export { concrete, declaredEventKinds, defaultEventSchema, eventDeclaration, eventSchema, field, pinContext, pinPrincipal, pinResource, pinnedField, principalType, record, renderEventSchema, resourceType, spreadInputs, spreadOutputs, } from "./event-schema.js";
|
|
23
|
+
export type { EventDeclaration, EventField, EventFieldType, EventSchema, EventSelector, NamedField, PinTarget, SpreadField, } from "./event-schema.js";
|
|
24
|
+
export { DOGWOOD_EVENT_SCHEMA_FILENAME, DOGWOOD_EVENT_SCHEMA_TYPE, DOGWOOD_LEXICON, DOGWOOD_MACRO_FILENAME, DOGWOOD_MACRO_LIBRARY_TYPE, DOGWOOD_POLICY_FILENAME, DOGWOOD_POLICY_TYPE, TemporalEventSchema, TemporalMacroLibrary, TemporalPolicy, } from "./policy.js";
|
|
25
|
+
export type { EventSchemaProps, MacroLibraryProps, TemporalPolicyProps } from "./policy.js";
|
|
26
|
+
export { DOGWOOD_EVENT_SCHEMA_SUFFIX, DOGWOOD_POLICY_SUFFIX, dogwoodPolicyRecords, renderTemporalPolicyText, serializeDogwood, } from "./serialize.js";
|
|
27
|
+
export type { DogwoodPolicyRecord, DogwoodSerializeResult } from "./serialize.js";
|
|
28
|
+
export { blankComments, dogwoodPolicyFiles, dogwoodSchemaFiles, effectiveMaxWindowSeconds, readEventSchema, scanPredicates, scanWindowlessOperators, scanWindows, temporalRegions, } from "./scan.js";
|
|
29
|
+
export type { DogwoodArtifact, EventSchemaFacts, TemporalPredicateRef, WindowRef } from "./scan.js";
|
|
30
|
+
export { DOGWOOD_UPSTREAM } from "./upstream.js";
|
|
31
|
+
export { DOGWOOD_BINARY_ENV, DOGWOOD_BINARY_NAME, DOGWOOD_SEARCH_ORDER, configureDogwoodCli, findDogwoodBinary, formatDogwoodDiagnostic, parseLowerOutput, parseReplayOutput, parseValidateOutput, resetDogwoodCli, runDogwoodLower, runDogwoodReplay, runDogwoodValidate, } from "./cli.js";
|
|
32
|
+
export type { DogwoodBinary, DogwoodBinarySource, DogwoodBundle, DogwoodDiagnostic, DogwoodFatal, DogwoodLabel, DogwoodLowerResult, DogwoodLowered, DogwoodReplayResult, DogwoodRun, DogwoodRunner, DogwoodUnusable, DogwoodValidateResult, DogwoodVerdict, } from "./cli.js";
|
|
33
|
+
export { auditTrace, decimalValue, entityRef, rawValue, renderTrace, renderTraceFields, renderTraceLine, renderTraceValue, traceEntity, traceEvent, traceFixture, } from "./trace.js";
|
|
34
|
+
export type { TraceAuditOptions, TraceBags, TraceDecimal, TraceEntityDecl, TraceEntityRef, TraceEvent, TraceEventInput, TraceFields, TraceFixture, TraceFixtureOptions, TraceIssue, TraceIssueKind, TraceRaw, TraceScope, TraceTagged, TraceValue, } from "./trace.js";
|
|
35
|
+
export { compareVerdicts, dogwoodReplay, dogwoodReplayReport, renderReplaySummary, resolveReplayInputs, } from "./replay-activity.js";
|
|
36
|
+
export type { DogwoodReplayArgs, DogwoodReplayReportArgs, ExpectedVerdict, PolicyReplayDispatch, PolicyReplayMode, PolicyReplayReport, ReplayDivergence, ReplayExpectation, } from "./replay-activity.js";
|
|
37
|
+
export { DEFAULT_REPLAY_REPORT_PATH, PolicyReplayOp, dogwoodReplayReportStep, dogwoodReplayStep, } from "./replay-op.js";
|
|
38
|
+
export type { DogwoodReplayReportStepOpts, DogwoodReplayStepOpts, PolicyReplayOpConfig, PolicyReplayOpResources, } from "./replay-op.js";
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dogwood/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,MAAM,EACN,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,E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AAU,EACV,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,cAAc,GACf,MAAM,OAAO,CAAC;AAIf,OAAO,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,eAAe,EACf,cAAc,EACd,UAAU,EACV,eAAe,EACf,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,GACX,MAAM,SAAS,CAAC;AAIjB,OAAO,EACL,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Macro authoring, and the default library as calls rather than operators.
|
|
3
|
+
*
|
|
4
|
+
* Upstream's policy grammar carries the macro system in the parser, not in the
|
|
5
|
+
* docs:
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* def_decl = { kw_def ~ def_kind ~ ident ~ "(" ~ param_list? ~ ")" ~ "{" ~ block_inner ~ "}" ~ ";" }
|
|
9
|
+
* def_kind = { kw_def_cedar | kw_def_temporal }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* A `cedar` macro's body is a Cedar expression; a `temporal` macro's body is a
|
|
13
|
+
* temporal condition *or* a bare aggregation value (upstream's
|
|
14
|
+
* `temporal_macro_body_entry` tries `agg_expr` first, which is why
|
|
15
|
+
* `count_within` can expand into a `count …` that the call site compares).
|
|
16
|
+
*
|
|
17
|
+
* Two sigils, and they are not interchangeable. `?p` splices the call-site
|
|
18
|
+
* argument literally. `$t` is a fresh binder the macro introduces, gensym'd at
|
|
19
|
+
* every expansion. Both are legal *only* inside a macro body — upstream's
|
|
20
|
+
* well-formedness pass rejects them anywhere else — which is why they are
|
|
21
|
+
* validated here at definition time rather than at render time.
|
|
22
|
+
*
|
|
23
|
+
* The four wrappers at the bottom are the default library
|
|
24
|
+
* (`configuration/default_macros.dw`). They are calls, not operators. A caller
|
|
25
|
+
* who passes `--macros` replaces that library entirely, so a policy built on
|
|
26
|
+
* them is built on an assumption about the other end; {@link defaultMacroLibrary}
|
|
27
|
+
* exists so a project can emit the same definitions itself and stop assuming.
|
|
28
|
+
*/
|
|
29
|
+
import { type CallNode, type SigilCondition, type TemporalCondition, type TemporalTerm, type TermText } from "./temporal.js";
|
|
30
|
+
import { type WindowLike, type WindowParam } from "./window.js";
|
|
31
|
+
/** Which sub-parser reads the body: Cedar's, or the temporal sub-language's. */
|
|
32
|
+
export type MacroKind = "cedar" | "temporal";
|
|
33
|
+
/** One `def <kind> <name>(<params>) { <body> };` declaration. */
|
|
34
|
+
export interface MacroDefinition {
|
|
35
|
+
readonly kind: MacroKind;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** Parameter names, each carrying the `?` sigil. */
|
|
38
|
+
readonly params: readonly string[];
|
|
39
|
+
/** Rendered body text. */
|
|
40
|
+
readonly body: string;
|
|
41
|
+
/** Emitted as `// …` lines above the definition. */
|
|
42
|
+
readonly comment?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* `def temporal name(?a, ?b) { … };`
|
|
46
|
+
*
|
|
47
|
+
* The body may be a condition or an aggregation term, matching upstream's
|
|
48
|
+
* `temporal_macro_body_entry`; `sum_within` is an aggregation-bodied macro and
|
|
49
|
+
* `once` is a condition-bodied one.
|
|
50
|
+
*/
|
|
51
|
+
export declare function defTemporalMacro(name: string, params: string[], body: TemporalCondition | TemporalTerm, comment?: string): MacroDefinition;
|
|
52
|
+
/**
|
|
53
|
+
* `def cedar name(?a) { … };` — the body is Cedar expression text.
|
|
54
|
+
*
|
|
55
|
+
* Cedar's expression grammar is the policy language itself, so it stays a
|
|
56
|
+
* string here for the same reason `Cedar::Policy`'s `when` does.
|
|
57
|
+
*/
|
|
58
|
+
export declare function defCedarMacro(name: string, params: string[], body: string, comment?: string): MacroDefinition;
|
|
59
|
+
/**
|
|
60
|
+
* `within ?w` — the window a macro body defers to its call site.
|
|
61
|
+
*
|
|
62
|
+
* The call site supplies a bare interval (`once(1h, …)`), not a `within`
|
|
63
|
+
* clause: the keyword belongs to the operator, so it stays in the body.
|
|
64
|
+
*/
|
|
65
|
+
export declare function macroWindow(param: string): WindowParam;
|
|
66
|
+
/** `?s` standing for an entire condition, spliced from the call site. */
|
|
67
|
+
export declare function macroCondition(param: string): SigilCondition;
|
|
68
|
+
/** `?a` / `$t` in term or binder position. */
|
|
69
|
+
export declare function macroTerm(sigil: string): TermText;
|
|
70
|
+
/** One definition as `.dw` source. */
|
|
71
|
+
export declare function renderMacroDefinition(def: MacroDefinition): string;
|
|
72
|
+
/** A whole library — the file `--macros` points at, or a policy set's own prelude. */
|
|
73
|
+
export declare function renderMacroLibrary(defs: readonly MacroDefinition[]): string;
|
|
74
|
+
/** The macro names `configuration/default_macros.dw` ships at the pinned revision. */
|
|
75
|
+
export declare const DEFAULT_MACRO_NAMES: readonly ["count_within", "sum_within", "count_distinct_within", "bind"];
|
|
76
|
+
/**
|
|
77
|
+
* `count_within(?w, ?s)` — timepoints in the window at which `?s` held.
|
|
78
|
+
*
|
|
79
|
+
* A default-library call, not an operator. See this module's header.
|
|
80
|
+
*/
|
|
81
|
+
export declare function countWithin(w: WindowLike, condition: TemporalCondition): CallNode;
|
|
82
|
+
/** `sum_within(?a, ?w, ?body)` — `over` names the sum's bound variable. */
|
|
83
|
+
export declare function sumWithin(over: string, w: WindowLike, body: TemporalCondition): CallNode;
|
|
84
|
+
/** `count_distinct_within(?k, ?w, ?s)` — distinct String keys `k` for which `s` held. */
|
|
85
|
+
export declare function countDistinctWithin(key: string, w: WindowLike, condition: TemporalCondition): CallNode;
|
|
86
|
+
/** `bind(?n, ?A, ?B)` — names an aggregate result so it can be compared. */
|
|
87
|
+
export declare function bind(name: string, aggregate: TemporalCondition, body: TemporalCondition): CallNode;
|
|
88
|
+
/**
|
|
89
|
+
* The default library's four definitions, verbatim from upstream's
|
|
90
|
+
* `dogwood-language/configuration/default_macros.dw` at the pinned revision.
|
|
91
|
+
*
|
|
92
|
+
* Emitting these into a project's own `macros.dw` turns an assumption about
|
|
93
|
+
* the callee's `--macros` into a file the project controls.
|
|
94
|
+
*/
|
|
95
|
+
export declare function defaultMacroLibrary(): MacroDefinition[];
|
|
96
|
+
//# sourceMappingURL=macros.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"macros.d.ts","sourceRoot":"","sources":["../../src/dogwood/macros.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAOL,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAe,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAM1E,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAE7C,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QA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