@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.
Files changed (149) hide show
  1. package/README.md +106 -2
  2. package/dist/agentcore/embed.d.ts +189 -0
  3. package/dist/agentcore/embed.d.ts.map +1 -0
  4. package/dist/agentcore/enforcement.d.ts +76 -0
  5. package/dist/agentcore/enforcement.d.ts.map +1 -0
  6. package/dist/agentcore/scan.d.ts +46 -0
  7. package/dist/agentcore/scan.d.ts.map +1 -0
  8. package/dist/codegen/docs-dogwood.d.ts +21 -0
  9. package/dist/codegen/docs-dogwood.d.ts.map +1 -0
  10. package/dist/codegen/docs.d.ts.map +1 -1
  11. package/dist/codegen/package.d.ts.map +1 -1
  12. package/dist/config.d.ts +25 -0
  13. package/dist/config.d.ts.map +1 -1
  14. package/dist/dogwood/cli.d.ts +247 -0
  15. package/dist/dogwood/cli.d.ts.map +1 -0
  16. package/dist/dogwood/event-schema.d.ts +161 -0
  17. package/dist/dogwood/event-schema.d.ts.map +1 -0
  18. package/dist/dogwood/index.d.ts +39 -0
  19. package/dist/dogwood/index.d.ts.map +1 -0
  20. package/dist/dogwood/macros.d.ts +96 -0
  21. package/dist/dogwood/macros.d.ts.map +1 -0
  22. package/dist/dogwood/policy.d.ts +120 -0
  23. package/dist/dogwood/policy.d.ts.map +1 -0
  24. package/dist/dogwood/replay-activity.d.ts +196 -0
  25. package/dist/dogwood/replay-activity.d.ts.map +1 -0
  26. package/dist/dogwood/replay-op.d.ts +165 -0
  27. package/dist/dogwood/replay-op.d.ts.map +1 -0
  28. package/dist/dogwood/scan.d.ts +109 -0
  29. package/dist/dogwood/scan.d.ts.map +1 -0
  30. package/dist/dogwood/serialize.d.ts +66 -0
  31. package/dist/dogwood/serialize.d.ts.map +1 -0
  32. package/dist/dogwood/temporal.d.ts +259 -0
  33. package/dist/dogwood/temporal.d.ts.map +1 -0
  34. package/dist/dogwood/trace.d.ts +215 -0
  35. package/dist/dogwood/trace.d.ts.map +1 -0
  36. package/dist/dogwood/upstream.d.ts +41 -0
  37. package/dist/dogwood/upstream.d.ts.map +1 -0
  38. package/dist/dogwood/window.d.ts +73 -0
  39. package/dist/dogwood/window.d.ts.map +1 -0
  40. package/dist/index.d.ts +12 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/integrity.json +15 -3
  43. package/dist/lint/audit-catalog.d.ts.map +1 -1
  44. package/dist/lint/post-synth/dogwood-helpers.d.ts +63 -0
  45. package/dist/lint/post-synth/dogwood-helpers.d.ts.map +1 -0
  46. package/dist/lint/post-synth/dwdc010.d.ts +25 -0
  47. package/dist/lint/post-synth/dwdc010.d.ts.map +1 -0
  48. package/dist/lint/post-synth/dwdc011.d.ts +19 -0
  49. package/dist/lint/post-synth/dwdc011.d.ts.map +1 -0
  50. package/dist/lint/post-synth/dwdc012.d.ts +21 -0
  51. package/dist/lint/post-synth/dwdc012.d.ts.map +1 -0
  52. package/dist/lint/post-synth/dwdc013.d.ts +33 -0
  53. package/dist/lint/post-synth/dwdc013.d.ts.map +1 -0
  54. package/dist/lint/post-synth/dwde010.d.ts +32 -0
  55. package/dist/lint/post-synth/dwde010.d.ts.map +1 -0
  56. package/dist/lint/post-synth/dwde011.d.ts +33 -0
  57. package/dist/lint/post-synth/dwde011.d.ts.map +1 -0
  58. package/dist/lint/post-synth/dwds010.d.ts +24 -0
  59. package/dist/lint/post-synth/dwds010.d.ts.map +1 -0
  60. package/dist/lint/post-synth/index.d.ts.map +1 -1
  61. package/dist/manifest.json +1 -1
  62. package/dist/okf/index.md +7 -0
  63. package/dist/okf/rules/DWDC010.md +11 -0
  64. package/dist/okf/rules/DWDC011.md +11 -0
  65. package/dist/okf/rules/DWDC012.md +11 -0
  66. package/dist/okf/rules/DWDC013.md +15 -0
  67. package/dist/okf/rules/DWDE010.md +11 -0
  68. package/dist/okf/rules/DWDE011.md +11 -0
  69. package/dist/okf/rules/DWDS010.md +11 -0
  70. package/dist/okf/types/Policy.md +1 -0
  71. package/dist/op/activities/index.d.ts +18 -0
  72. package/dist/op/activities/index.d.ts.map +1 -0
  73. package/dist/plugin.d.ts.map +1 -1
  74. package/dist/policy-text.d.ts +53 -0
  75. package/dist/policy-text.d.ts.map +1 -0
  76. package/dist/rules/dogwood-helpers.ts +139 -0
  77. package/dist/rules/dwdc010.ts +62 -0
  78. package/dist/rules/dwdc011.ts +61 -0
  79. package/dist/rules/dwdc012.ts +46 -0
  80. package/dist/rules/dwdc013.ts +64 -0
  81. package/dist/rules/dwde010.ts +130 -0
  82. package/dist/rules/dwde011.ts +108 -0
  83. package/dist/rules/dwds010.ts +46 -0
  84. package/dist/serializer.d.ts +10 -18
  85. package/dist/serializer.d.ts.map +1 -1
  86. package/dist/skills/chant-cedar-authoring.md +180 -0
  87. package/dist/skills/chant-cedar-avp-embedding.md +125 -0
  88. package/dist/skills/chant-cedar-dogwood.md +327 -0
  89. package/dist/skills/chant-cedar-meta-policy.md +119 -0
  90. package/package.json +7 -2
  91. package/src/agentcore/embed.test.ts +254 -0
  92. package/src/agentcore/embed.ts +399 -0
  93. package/src/agentcore/enforcement.test.ts +43 -0
  94. package/src/agentcore/enforcement.ts +92 -0
  95. package/src/agentcore/scan.ts +119 -0
  96. package/src/codegen/docs-dogwood.ts +1119 -0
  97. package/src/codegen/docs.ts +66 -1
  98. package/src/codegen/package.ts +3 -2
  99. package/src/config.test.ts +12 -0
  100. package/src/config.ts +28 -0
  101. package/src/dogwood/cli.test.ts +513 -0
  102. package/src/dogwood/cli.ts +666 -0
  103. package/src/dogwood/event-schema.test.ts +218 -0
  104. package/src/dogwood/event-schema.ts +318 -0
  105. package/src/dogwood/index.ts +271 -0
  106. package/src/dogwood/macros.test.ts +104 -0
  107. package/src/dogwood/macros.ts +229 -0
  108. package/src/dogwood/policy.test.ts +94 -0
  109. package/src/dogwood/policy.ts +141 -0
  110. package/src/dogwood/replay-activity.test.ts +481 -0
  111. package/src/dogwood/replay-activity.ts +506 -0
  112. package/src/dogwood/replay-op.ts +242 -0
  113. package/src/dogwood/scan.ts +287 -0
  114. package/src/dogwood/serialize.test.ts +331 -0
  115. package/src/dogwood/serialize.ts +246 -0
  116. package/src/dogwood/temporal.test.ts +272 -0
  117. package/src/dogwood/temporal.ts +592 -0
  118. package/src/dogwood/testdata/custom-kinds.dwschema +17 -0
  119. package/src/dogwood/testdata/default-macros.dw +23 -0
  120. package/src/dogwood/testdata/lowered-read-after-login.json +13 -0
  121. package/src/dogwood/testdata/max-window-raised.dwschema +25 -0
  122. package/src/dogwood/testdata/pinned.dwschema +31 -0
  123. package/src/dogwood/testdata/read-after-login.cedarschema +20 -0
  124. package/src/dogwood/testdata/read-after-login.dw +17 -0
  125. package/src/dogwood/testdata/temporal-policies.dw +53 -0
  126. package/src/dogwood/trace.test.ts +231 -0
  127. package/src/dogwood/trace.ts +471 -0
  128. package/src/dogwood/upstream.ts +41 -0
  129. package/src/dogwood/window.ts +124 -0
  130. package/src/index.ts +76 -0
  131. package/src/lint/audit-catalog.ts +64 -0
  132. package/src/lint/post-synth/dogwood-helpers.ts +139 -0
  133. package/src/lint/post-synth/dwd-post-synth.test.ts +374 -0
  134. package/src/lint/post-synth/dwdc010.ts +62 -0
  135. package/src/lint/post-synth/dwdc011.ts +61 -0
  136. package/src/lint/post-synth/dwdc012.ts +46 -0
  137. package/src/lint/post-synth/dwdc013.ts +64 -0
  138. package/src/lint/post-synth/dwde-post-synth.test.ts +368 -0
  139. package/src/lint/post-synth/dwde010.ts +130 -0
  140. package/src/lint/post-synth/dwde011.ts +108 -0
  141. package/src/lint/post-synth/dwds010.ts +46 -0
  142. package/src/lint/post-synth/index.ts +14 -0
  143. package/src/lint/post-synth/post-synth.test.ts +7 -3
  144. package/src/op/activities/index.ts +27 -0
  145. package/src/plugin.test.ts +3 -2
  146. package/src/plugin.ts +30 -0
  147. package/src/policy-text.ts +128 -0
  148. package/src/serializer.ts +71 -109
  149. package/src/skills/chant-cedar-dogwood.md +327 -0
@@ -0,0 +1,327 @@
1
+ ---
2
+ skill: chant-cedar-dogwood
3
+ description: Author dogwood temporal policies with the cedar lexicon's typed builders — the parser primitives, the macro caveat, the validation split, AgentCore embedding, and replay
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Temporal Policies with the Dogwood Dialect
8
+
9
+ ## Read this part first
10
+
11
+ Dogwood is pre-release, and the framing matters more than usual because it
12
+ changes what you should write.
13
+
14
+ Upstream (`dogwood-policy/dogwood`, Apache-2.0) says on its own README, in
15
+ bold, that it is **not intended for production use**. It is a reference
16
+ interpreter with enumerated gaps: no event timestamp validation, no event
17
+ authentication, no trace durability, unsandboxed Rhai in providers, no audit
18
+ logging, no multi-tenancy isolation, and an `http_get` provider with no SSRF
19
+ protection.
20
+
21
+ It also has no versioning story at all. Zero tags, zero releases, no changelog.
22
+ The crate reports `1.0.0` because it is published to an Amazon-internal
23
+ registry, and every future sync will also report `1.0.0`. The repository is a
24
+ read-only mirror: content arrives as squashed "Sync from internal source"
25
+ commits from a publish bot, against a repository nobody outside Amazon can see,
26
+ at a cadence of roughly one sync every three days over its public life.
27
+
28
+ chant pins a git SHA plus the blob hashes of seven files in
29
+ `src/dogwood/upstream.ts`. Do not tell a user this surface is stable. Do tell
30
+ them what is pinned and what a sync can move.
31
+
32
+ ## The one distinction to get right
33
+
34
+ **`formerly`, `previous`, `since`, `exists`, `tp()`, `count for … where` and
35
+ `sum … for … where` are the parser primitives.** They are the entire temporal
36
+ keyword set in upstream's grammar, and they are what the typed builders target.
37
+
38
+ **`count_within`, `sum_within`, `count_distinct_within` and `bind` are macros**
39
+ in a swappable default library (`configuration/default_macros.dw`). A caller
40
+ who passes `--macros` replaces that library wholesale, so a policy built on
41
+ them is built on an assumption about the far end.
42
+
43
+ **`once` does not ship at all.** It appears in upstream's examples as an
44
+ ordinary user-defined macro and is in no library. (The grammar rule behind
45
+ `formerly` is internally named `once_op`, which is where the confusion comes
46
+ from.) If a user asks for `once`, define it as a macro or use `formerly`
47
+ directly — do not emit a bare `once(…)` call and hope.
48
+
49
+ So: the four aggregates are expressible as **calls**
50
+ (`dogwood.countWithin(…)`), never as operators. A missing macro at the far end
51
+ is a comprehensible error. A builder that emits a name the callee's library
52
+ does not define is a mystery.
53
+
54
+ The way to stop assuming is to ship the definitions:
55
+
56
+ ```typescript
57
+ import { TemporalMacroLibrary, dogwood } from "@intentius/chant-lexicon-cedar";
58
+
59
+ // Upstream's four definitions, verbatim, into the project's own macros.dw.
60
+ export const macros = new TemporalMacroLibrary({ macros: dogwood.defaultMacroLibrary() });
61
+ ```
62
+
63
+ With `inline: true` they go at the top of `policies.dw` instead, and a policy
64
+ set's own `def` shadows a same-named library macro — the strongest form,
65
+ because the definitions travel with the policies.
66
+
67
+ ## Authoring
68
+
69
+ ```typescript
70
+ import { TemporalPolicy, TemporalEventSchema, dogwood } from "@intentius/chant-lexicon-cedar";
71
+
72
+ export const events = new TemporalEventSchema({ schema: dogwood.defaultEventSchema() });
73
+
74
+ export const readAfterLogin = new TemporalPolicy({
75
+ annotations: { id: "read_after_login" },
76
+ action: { eq: 'Drupe::Action::"Read"' },
77
+ whenTemporal: [
78
+ dogwood.formerly(
79
+ "1h",
80
+ dogwood.predicate('Drupe::Action::"Login"', "response", {
81
+ "input.user": dogwood.ctx("input.user"),
82
+ }),
83
+ ),
84
+ ],
85
+ });
86
+ ```
87
+
88
+ Emits:
89
+
90
+ ```
91
+ @id("read_after_login")
92
+ permit (
93
+ principal,
94
+ action == Drupe::Action::"Read",
95
+ resource
96
+ )
97
+ when temporal {
98
+ formerly within 1h Drupe::Action::"Login"::response{ input.user: context.input.user }
99
+ };
100
+ ```
101
+
102
+ ### Clause forms
103
+
104
+ | Prop | Emits |
105
+ |---|---|
106
+ | `when` / `unless` | `when { … }` — Cedar expression strings, same as `Cedar::Policy` |
107
+ | `whenGuardrails` / `unlessGuardrails` | `when guardrails { … }` — a Cedar expression with a tag upstream discards when lowering |
108
+ | `whenTemporal` / `unlessTemporal` | `when temporal { … }` — the temporal sub-language |
109
+
110
+ ### Windows
111
+
112
+ `formerly`, `previous` and `since` all take a mandatory window: an integer and
113
+ one of `s`, `m`, `h`, `d`. Nothing else parses. The builders take it as an
114
+ argument, so a windowless operator is unrepresentable — do not reach for
115
+ `dogwood.raw()` to work around a window you do not want, because there is no
116
+ such form.
117
+
118
+ Every operator is past-only. There is no future operator and no way to write
119
+ one. A user asking for "deny if X happens later" needs a different design.
120
+
121
+ ### Terms
122
+
123
+ Numbers and booleans lift. A bare string does not, on purpose: `"alice"` is a
124
+ Cedar string literal and `alice` is a binder reference, and guessing is how a
125
+ policy silently stops matching. Say which:
126
+
127
+ | Builder | Renders |
128
+ |---|---|
129
+ | `dogwood.str("alice")` | `"alice"` |
130
+ | `dogwood.varRef("a")` | `a` |
131
+ | `dogwood.ctx("input.user")` | `context.input.user` |
132
+ | `dogwood.scopeRef("principal", "dept")` | `principal.dept` |
133
+ | `dogwood.entityUid('Drupe::OAuthUser::"alice"')` | `Drupe::OAuthUser::"alice"` |
134
+
135
+ ### An aggregate, from the primitive
136
+
137
+ ```typescript
138
+ export const rateLimited = new TemporalPolicy({
139
+ annotations: { id: "rate_limited" },
140
+ action: { eq: 'Drupe::Action::"Transfer"' },
141
+ whenTemporal: [
142
+ dogwood.compare(
143
+ dogwood.count(
144
+ [dogwood.typedBinder("t", "Timepoint")],
145
+ dogwood.formerly(
146
+ "15m",
147
+ dogwood.and(dogwood.predicate('Drupe::Action::"Transfer"', "request"), dogwood.tp("t")),
148
+ ),
149
+ ),
150
+ "<",
151
+ 5,
152
+ ),
153
+ ],
154
+ });
155
+ ```
156
+
157
+ That is what `count_within` expands to. Writing it directly costs four lines
158
+ and depends on nothing at the far end.
159
+
160
+ ## The event schema, and the pin
161
+
162
+ `.dwschema` is the optional service half of the schema; the required half is
163
+ the Cedar `.cedarschema` the rest of the lexicon already generates from. They
164
+ are two halves of one schema, not competing formats.
165
+
166
+ The default event schema pins `callerPrincipal = principal` on every kind, so
167
+ every temporal predicate is correlated to the deciding request's principal and
168
+ other principals' events are invisible.
169
+
170
+ **Supplying any event schema opts out of upstream's default wholesale.** A
171
+ schema emitted without a pin does not merely fail to add a correlation — it
172
+ removes one the author probably assumed, and every predicate in the set starts
173
+ matching across principals. `dogwood.defaultEventSchema()` carries the pin;
174
+ dropping it is a named argument that stamps a comment into the emitted file:
175
+
176
+ ```typescript
177
+ dogwood.defaultEventSchema({ pinCallerPrincipal: false });
178
+ ```
179
+
180
+ DWDS010 warns about an unpinned emitted schema. That is report-only — chant
181
+ does not know which the author wanted, only that the choice should be visible
182
+ in a diff.
183
+
184
+ `max_window` caps look-back for the whole set; absent, it is 24h — the same 24h
185
+ that applies when no schema is supplied at all.
186
+
187
+ ## Deploying to AgentCore
188
+
189
+ `AWS::BedrockAgentCore::Policy` is the vehicle. Its `Definition` is a two-arm
190
+ `oneOf` — `Cedar.Statement` for plain Cedar, `Policy.Statement` for anything
191
+ else — and a `.dw` policy travels in the second arm.
192
+
193
+ ```typescript
194
+ import { agentCoreStagedPolicy } from "@intentius/chant-lexicon-cedar";
195
+
196
+ new BedrockAgentCorePolicy({
197
+ PolicyEngineId: engine.ref(),
198
+ ...agentCoreStagedPolicy("writeNeedsApproval", writeNeedsApproval, "log-only"),
199
+ });
200
+ ```
201
+
202
+ `agentCorePolicyDefinition(name, policy)` picks the arm from the policy itself.
203
+ Templates are refused — AgentCore's union has no template-linked arm, so a
204
+ statement carrying `?principal` or `?resource` throws at authoring time rather
205
+ than failing at deploy.
206
+
207
+ `EnforcementMode` stages the rollout: `"log-only"` is evaluated on every request
208
+ with its decision observed rather than returned, `"enforce"` binds. Start a
209
+ temporal policy log-only — whether it fires depends on traffic nobody has
210
+ replayed. Promotion is a one-token diff.
211
+
212
+ The resource carries a statement and nothing else, so the event schema is
213
+ registered with the engine separately; DWDC013 warns when temporal text is
214
+ embedded and no `.dwschema` was emitted beside it.
215
+
216
+ ## The validation split
217
+
218
+ Explain this split when a user asks why something did or did not fail.
219
+
220
+ Always, gating, no binary anywhere:
221
+
222
+ | Check | Catches |
223
+ |---|---|
224
+ | DWDC010 | A temporal predicate naming an event kind the emitted `.dwschema` never declares |
225
+ | DWDC011 | A window past `max_window` (or upstream's 24h default) — macro-call intervals count |
226
+ | DWDC012 | A `formerly`/`previous`/`since` with no `within` window |
227
+ | DWDC013 | An AgentCore-embedded temporal statement with no `.dwschema` emitted beside it (warning) |
228
+ | DWDS010 | An emitted event schema that pins nothing (warning) |
229
+
230
+ Only when the `dogwood` binary is present:
231
+
232
+ | Check | Catches |
233
+ |---|---|
234
+ | DWDE010 | Everything `dogwood validate` catches — macro expansion, the temporal type check, the Cedar body against the action schema |
235
+ | DWDE011 | The `dogwood lower` output failing Cedar's own validator via `@cedar-policy/cedar-wasm` |
236
+
237
+ Binary resolution order: an explicit `configureDogwoodCli({ binary })`, then
238
+ `$CHANT_DOGWOOD_BINARY`, then `cedar.dogwood.binary` in a `chant.config.json`,
239
+ then `dogwood` on `PATH`. There is no published build — it is `cargo build
240
+ --release` from the pinned revision.
241
+
242
+ When it is absent, DWDE010 emits exactly one `info` finding naming the binary,
243
+ where chant looked, and the issue. It never silently passes: a check that
244
+ quietly succeeds when it could not run is claiming a guarantee it did not make.
245
+
246
+ Nothing in gating CI runs the binary, by design.
247
+
248
+ ### Do not read exit codes
249
+
250
+ If you write anything that shells to the CLI: exit 2 means both "policy set
251
+ rejected" and clap's usage error for an unknown flag, and upstream's own guide
252
+ claims 1 for the latter. The JSON on stdout decides, in both directions. There
253
+ are two JSON shapes — a validate report (`passed`, `errors[]`, `warnings[]`)
254
+ and a bare fatal error object with the same diagnostic fields flattened plus
255
+ `related[]`. A run that produced neither is "could not be used", never "your
256
+ policy is bad".
257
+
258
+ ## Replay
259
+
260
+ A temporal policy is not decidable from its source — whether `formerly within
261
+ 1h …` fires depends on history nobody has replayed — so the check is a replay
262
+ against recorded traffic. That ships as `PolicyReplayOp`:
263
+
264
+ ```typescript
265
+ import { PolicyReplayOp } from "@intentius/chant-lexicon-cedar";
266
+
267
+ export const { op } = PolicyReplayOp({
268
+ name: "policy-replay",
269
+ policiesPath: "dist/policies.dw",
270
+ policySchemaPath: "schema.cedarschema",
271
+ eventSchemaPath: "dist/events.dwschema",
272
+ tracePath: "trace/read-after-login.log",
273
+ expect: [
274
+ { timestamp: 10, verdict: "allow", determiningRules: [0] },
275
+ { timestamp: 7200, verdict: "deny", note: "the login is two hours stale" },
276
+ ],
277
+ onFinding: "report",
278
+ });
279
+ ```
280
+
281
+ Three phases — Artifacts (`chantBuild`, skippable with `buildScript: false`),
282
+ Replay (`dogwoodReplay`, writes `dist/dogwood-replay.json`), Report
283
+ (`dogwoodReplayReport`, acts on `report | issue | pull-request`).
284
+ `failOnDivergence` defaults to false: an observe-dial Op reports. The composite
285
+ ships from cedar and carries no dependency on the temporal lexicon; a scheduled
286
+ form is a project-side `TemporalSchedule` pairing.
287
+
288
+ Build traces with `dogwood.traceEvent()` rather than by hand. Two traps it
289
+ exists to close, and both are worth naming whenever a user assembles a fixture:
290
+
291
+ 1. **Both bags.** A trace line carries a `request_context(...)` envelope, which
292
+ the Cedar request is built from, and a trailing logged record, which temporal
293
+ predicates match against. A field both halves need must be in both.
294
+ `traceEvent()` writes a `context` group into both by default; getting the
295
+ weaker trace takes an explicit `bags: "record-only"` / `"context-only"`.
296
+ Populate one bag only and nothing errors — the other check silently weakens.
297
+ 2. **Fully-qualified action names.** `Drupe::Action::"Transfer"`, never
298
+ `Transfer`. A bare name still authorizes through Cedar while every temporal
299
+ predicate quietly fails to match. `traceEvent()` rejects one at construction.
300
+
301
+ `dogwood.auditTrace(events)` applies the same checks to a trace chant did not
302
+ build (`single-bag`, `no-request-context`, `empty-record`, `out-of-order`), and
303
+ `dogwood.traceFixture(events)` throws rather than handing back a weakened one.
304
+
305
+ Write expectations against `timestamp`, not `index`: `index` is the position in
306
+ the decision stream, and a history-only event (any kind the schema does not
307
+ mark `decision`) contributes history and no verdict, so the two do not line up.
308
+ `determiningRules` catches a decision that is right for the wrong reason.
309
+
310
+ Replay exits 0 even when every verdict is DENY, so the activity reads the JSON
311
+ rather than the exit status — and a run that could not happen throws instead of
312
+ reporting zero divergences.
313
+
314
+ ## What chant does not do
315
+
316
+ - **No lowering.** `dogwood lower` owns that; a reimplementation would drift on
317
+ the next sync. Where the lowered form is wanted, chant shells to the binary.
318
+ - **No request-time evaluation.** The policy engine in front of the traffic
319
+ decides; chant has no seat there. The offline half is `PolicyReplayOp`, which
320
+ replays recorded history through upstream's interpreter.
321
+ - **No gate.** Dogwood is a target, the same as Cedar. Organizational policy in
322
+ chant is TypeScript post-synth checks.
323
+
324
+ ## Reference
325
+
326
+ Full pages: `/chant/lexicons/cedar/dogwood/`, and from there temporal policies,
327
+ event schemas, validation and replay.
@@ -0,0 +1,119 @@
1
+ ---
2
+ skill: chant-cedar-meta-policy
3
+ description: Organizational policy over Cedar policy sets — the bare-permit wall, forbid conventions, and env-aware severity
4
+ user-invocable: true
5
+ ---
6
+
7
+ # Policy About Policy
8
+
9
+ ## The ruling this sits under
10
+
11
+ Cedar is a target, never chant's gate. There is no `cedarGate()` and there will
12
+ not be one: organizational policy in chant is TypeScript post-synth checks, and
13
+ a second policy engine would duplicate the lint engine and break "TypeScript is
14
+ the one language."
15
+
16
+ So the rules below are ordinary `PostSynthCheck`s and lint rules under the `CED`
17
+ prefix. They read the emitted policy set the way any other check reads emitted
18
+ YAML. Cedar's own validator runs beside them, in-process, through
19
+ `@cedar-policy/cedar-wasm` — no CLI on PATH, no Docker.
20
+
21
+ ## The bare-permit wall
22
+
23
+ ```cedar
24
+ permit (principal, action, resource);
25
+ ```
26
+
27
+ Every scope position unconstrained, no `when`, no `unless`. It grants every
28
+ principal every action on every resource. It is legal Cedar, it validates
29
+ clean, and it is the single most damaging line a policy set can contain.
30
+
31
+ The rule is **env-aware, not absolute**:
32
+
33
+ | Environment | Verdict |
34
+ |---|---|
35
+ | dev / local | warn — a scratch policy set during development is a normal state |
36
+ | staging | warn, and expect it fixed before promotion |
37
+ | **prod** | **fail the build** |
38
+
39
+ Env-aware because an absolute rule gets suppressed the first time it fires
40
+ during development, and a suppressed rule protects nothing. Failing only where
41
+ the blast radius is real keeps the wall credible.
42
+
43
+ A permit with any of the following is not bare and does not trip the wall:
44
+
45
+ - a constrained scope position (`is`, `in`, `==`) on principal, action, or
46
+ resource, or
47
+ - at least one `when` or `unless` clause.
48
+
49
+ ## Schema-absent references
50
+
51
+ A policy naming an entity type or action the schema does not declare fails
52
+ **everywhere** — dev included. There is no environment where that is intended.
53
+ Two distinct failure modes hide behind it:
54
+
55
+ 1. **The typo.** `App::Documnt`. With generated classes this is a compile error
56
+ before any check runs, which is the point of the codegen. It survives only in
57
+ hand-written expression strings inside `when`/`unless`.
58
+ 2. **The silent no-op.** A scope naming an entity type outside the schema
59
+ *parses*, and `getValidRequestEnvsPolicy` answers "success, nothing" — an
60
+ empty request envelope. The policy is well-formed, deployed, and can never
61
+ fire. `cedar:coverage` reports these under `inert`.
62
+
63
+ ## Forbid conventions
64
+
65
+ Cedar is default-deny, so a `forbid` is never about the absence of a grant. It
66
+ is about the presence of a bad one: a forbid beats every permit in the set
67
+ unconditionally, which makes it the only construct that survives a later, wider
68
+ grant somebody adds next quarter.
69
+
70
+ Three conventions follow:
71
+
72
+ **Every forbid carries a guard.** An unguarded `forbid (principal, action,
73
+ resource)` denies everything and no permit can lift it — the policy set
74
+ authorizes nothing. `DenyByDefaultSet` throws on an empty `when` for this
75
+ reason.
76
+
77
+ **A forbid and the permits it governs ship together.** Separated, the forbid
78
+ gets deleted during a refactor and the permits keep working, wider than anyone
79
+ intended. `DenyByDefaultSet({ policies, when })` returns both from one call.
80
+
81
+ **Sensitive resources get an explicit floor, not just an absent permit.**
82
+ "Nobody wrote a permit for it" and "a forbid says no" look identical at
83
+ evaluation time and completely different in review. `cedar:coverage`'s
84
+ `forbidOnly` list is how you find declarations that have a floor; its
85
+ `uncovered` list is how you find the ones relying on absence.
86
+
87
+ ## Cross-domain checks
88
+
89
+ This is the thing no Cedar tool can express, because Cedar only ever sees
90
+ policies. In a chant build, policies and the infrastructure they govern are in
91
+ one entity graph, so a post-synth check can span both:
92
+
93
+ - an entity id in a policy references an actual resource declaration
94
+ - every declared bucket is covered by at least one `forbid`
95
+ - no schema action lacks any policy
96
+
97
+ These are ordinary post-synth checks. They are the differentiator, and they only
98
+ work because the policy set and the estate are built together.
99
+
100
+ ## Severity, by environment
101
+
102
+ | Finding | dev | staging | prod |
103
+ |---|---|---|---|
104
+ | Bare permit | warn | warn | fail |
105
+ | Entity type or action absent from schema | fail | fail | fail |
106
+ | Unguarded forbid | fail | fail | fail |
107
+ | Policy with an empty request envelope (inert) | warn | warn | fail |
108
+ | Schema action no policy covers | info | warn | warn |
109
+ | Entity type reachable only from a forbid | info | info | info |
110
+
111
+ The last row is deliberately never a failure. A resource nothing grants access
112
+ to is frequently correct.
113
+
114
+ ## Where these live
115
+
116
+ Post-synth checks and their catalog entries are **INTENTIUS/chant#1651**'s
117
+ scope. This skill describes the conventions the checks encode; if you are
118
+ writing a check, put it in `src/lint/post-synth/` with a `CED` id and an
119
+ `auditCatalog()` entry, not in a policy file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-cedar",
3
- "version": "0.44.8",
3
+ "version": "0.44.10",
4
4
  "description": "Cedar lexicon for chant — typed authoring for Cedar authorization policies",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -45,6 +45,11 @@
45
45
  "types": "./dist/lint/post-synth/index.d.ts",
46
46
  "default": "./src/lint/post-synth/index.ts"
47
47
  },
48
+ "./op/activities": {
49
+ "development": "./src/op/activities/index.ts",
50
+ "types": "./dist/op/activities/index.d.ts",
51
+ "default": "./src/op/activities/index.ts"
52
+ },
48
53
  "./manifest": "./dist/manifest.json",
49
54
  "./meta": "./dist/meta.json",
50
55
  "./types": "./dist/types/index.d.ts"
@@ -69,7 +74,7 @@
69
74
  },
70
75
  "peerDependencies": {
71
76
  "zod": "^4.3.6",
72
- "@intentius/chant": "^0.44.8",
77
+ "@intentius/chant": "^0.44.10",
73
78
  "typescript": "^5.9.3"
74
79
  }
75
80
  }