Repository navigation
feat(cedar): dogwood temporal dialect — typed builders, .dw serialization, event schemas (#1658) - #1672
Merged
Conversation
…tion, event schemas (#1658) Dogwood ships as a dialect inside the cedar lexicon under extraRulePrefixes: ["DWD"], not as a sibling lexicon: a .dw file stripped of Cedar semantics is meaningless, and a .dw policy's head is a Cedar policy's head byte for byte. The builders target the parser primitives, per the correction on #1646 and the count for … where and sum … for … where are the only temporal keywords in upstream's grammar; count_within, sum_within and count_distinct_within are macros in a default library a --macros flag replaces wholesale, so they are expressible as calls and never as operators. def-macro authoring covers both kinds and both sigils. The .dw leg runs inside the cedar serializer and shares its rendering through a new src/policy-text.ts rather than a copy. Event schemas are typed against upstream's 136-line .dwschema grammar, with the callerPrincipal pin on by default — dropping it takes a named argument and stamps its reasoning into the file. Four DWD walls, all answerable without the dogwood binary: an undeclared event kind (DWDC010), a window past max_window or the 24h default (DWDC011), a windowless past-only operator (DWDC012, which the builders already make unrepresentable), and an event schema that pins nothing (DWDS010, report-only). Nothing here shells to the CLI; that is #1659's. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018FAMfgpQTVDnsnqJzyHasZ
lex00
marked this pull request as ready for review
August 10, 2026 20:32
This was referenced Aug 10, 2026
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1658. Part of epic #1646.
Rebased onto
chant-v0.44.8(65ecd4c) — the hold is lifted and this is ready for review. It sits on top of #1667, #1668 and #1669; the reconciliation notes are at the bottom.What this is
The dogwood surface, inside
lexicons/cedarunderextraRulePrefixes: ["DWD"]. New code lives insrc/dogwood/; the touches elsewhere are the serializer hook, the audit-catalog entries, the regenerated post-synth barrel, and one shared-helper extraction.Built against the corrections on #1646 and the empirical report on #1657, re-verified against upstream at the pinned revision (the three
.pestgrammars,default_macros.dw,pinned.dwschemaand four example bundles were read directly while writing this, not recalled).Surface
Typed temporal builders (
src/dogwood/temporal.ts) targeting the parser primitives, which is the whole point of the correction:formerly,previous,since(window mandatory, unitss|m|h|d),exists,tp(),count for … where,sum … for … where, plus predicates, comparisons,&&,!, and the term forms.count_within,sum_withinandcount_distinct_withinare macro calls (dogwood.countWithin(…)), never operators — a caller passing--macrosreplaces the default library wholesale, so a first-class builder for them would emit a name that may not exist at the far end.dogwood.defaultMacroLibrary()emits upstream's four definitions so a project can stop assuming.The renderer parenthesises rather than trusting the reader to know the grammar: an
&&chain inatomposition, asinceon the left of anothersince, anexistsinside a conjunction (it binds maximally right), an aggregate in comparison position (itswherebody is greedy). Each has a test naming the rule it protects.def-macro authoring (
src/dogwood/macros.ts) for bothdef cedaranddef temporal, with?paramand$bindervalidated at definition time — upstream's well-formedness pass rejects sigils outside a macro body, somacroWindow/macroCondition/macroTermare the three positions they legally appear in.Dogwood::TemporalPolicy(src/dogwood/policy.ts) —Cedar::Policy's props pluswhenTemporal/unlessTemporalandwhenGuardrails/unlessGuardrails, matching upstream'scondrule. AlsoDogwood::EventSchemaandDogwood::MacroLibrary.The
.dwserializer leg runs inside the cedar serializer and emitspolicies.dw,events.dwschemaandmacros.dwalongside the cedar outputs when the build holds temporal entities; a cedar-only build is byte-identical to before. The policy head, scope forms andwhen/unlessbodies come from a newsrc/policy-text.tsthat every renderer imports — extracted, not duplicated, so a change to how a scope constraint is written moves all three.Event schemas (
src/dogwood/event-schema.ts) typed against the 136-line.dwschemagrammar: themax_windowdirective,[decision] event <A>::kind { … },...inputs(A)/...outputs(A)spreads, selector/record/concrete field types, andpin … = principal|resource|context.<path>.defaultEventSchema()carriespin callerPrincipal = principal; opting out takes{ pinCallerPrincipal: false }, which also stamps the reasoning into the emitted file — supplying any schema opts out of upstream's default wholesale, so an unpinned schema widens every predicate in the set.Walls
Four DWD checks, auto-discovered, catalogued, none of them shelling to anything:
.dwschemanever declaresmax_window, or upstream's 24h default when there is noneformerly/previous/sincewith nowithinDWDC012 is unrepresentable through the builders — the window is a required argument — and the check reads the serialized text anyway, because
raw()exists, a.dwcan come from any other tool, andchant auditruns over files chant never wrote.Deviations, called out
DWDC010 checks the event kind, not the action. The issue asks for "an event kind or action absent from the emitted event schema", but the
.dwschemagrammar declares events against a symbolic action binder (decision event <A>::request) and names no actions at all — there is nothing in the file to check an action against. The action half of upstream's error comes from the Cedar action schema via--policy-schema, which is #1659's CLI-gated leg. Implementing a.cedarschemascan here would have been dead code with no emitter behind it.DWDS010 is a fourth check the issue did not list. It is how "emitting a schema that opts out of the pin must be a deliberate, documented choice" becomes visible in a build rather than only in the source.
src/policy-text.tsis a new file outsidesrc/dogwood/. The issue asked to extract shared helpers rather than duplicate; keeping them inserializer.tsand importing them from the dialect would have made a module cycle.serializer.tsre-exports everything it used to export, so no caller changes.Filenames are
policies.dw/events.dwschema/macros.dw, plural to matchpolicies.cedar.json; upstream's examples use the singular. Both are overridable per entity.Rebase notes (post-0.44.8)
serializer.tsvs feat(cedar): AVP embedding + policy-store observation with ownership channel (#1652) #1668. The.dwleg sits on top ofcedarPolicyRecords, not beside it: the cedar half ofserialize()is untouched, and the dogwood call is appended after the record loop. What changed in the cedar path is only that the result is assembled from afiles/warningspair instead of two early returns, so a temporal-only build can emit its files with an empty.cedarprimary.resolvePolicyIdmoved intopolicy-text.ts. feat(cedar): AVP embedding + policy-store observation with ownership channel (#1652) #1668 extracted it fromserialize()for the AVP observation; the.dwleg needs the same rule for the same reason, so the third caller made it a shared helper rather than a serializer-local one. Re-exported fromserializer.ts, soavp/describe-resources.tsand the package root are unchanged.policy-text.tsvs feat(cedar): import/export round-trip + valid JSON policy leg (#1653) #1666's helpers. Reconciled, not duplicated:renderPolicyText(which the AVP statement renderer calls) now builds onrenderPolicyHead, so the annotation and scope rendering has exactly one implementation feeding.cedar, AVP statements and.dw.package.jsonuntouched at 0.44.8.Gates
tsc -p lexicons/cedar/tsconfig.build.json— cleannpm run build -w @intentius/chant-lexicon-cedar— cleannpx vitest run lexicons/cedar— 498 passed / 31 files (was 456 / 26 on main)npx vitest run packages/core— 4242 passed / 288 files, including the audit-catalog coverage tests that now see the four DWD entriesnpx tsx scripts/check-lexicons.ts— cedar 21/21 tier-1, including the rule-prefix check that theDWDfamily exists to satisfynpx tsx scripts/typecheck.ts— 85 known failures, no regressionsnode scripts/depcheck.mjs— no undeclared runtime dependenciesNothing in gating CI executes the dogwood binary, per the epic.
Not in scope
CLI-gated full validation and the wasm check of the non-temporal body (#1659), the AgentCore embedding (#1660),
PolicyReplayOp(#1661), and the docs page in the cedar sidebar (#1662) — the README gains a section saying the dialect exists and is pre-release, and no more. #1677 stacks on this.Attribution
Fixtures under
src/dogwood/testdata/are adapted fromdogwood-policy/dogwood(Apache-2.0) at5063bcc2d6d6cf5024d1b0498e6cc8ef52cbcf0c; each file names its upstream source in a header comment. The pin and its narrow content hashes are recorded insrc/dogwood/upstream.ts.🤖 Generated with Claude Code
https://claude.ai/code/session_018FAMfgpQTVDnsnqJzyHasZ