Repository navigation
feat(cedar): dogwood CLI-gated validation split (#1659) - #1677
Merged
Merged
Conversation
This was referenced Aug 10, 2026
lex00
force-pushed
the
dogwood/validation
branch
from
August 10, 2026 20:36
a272e14 to
7cd77c9
Compare
lex00
marked this pull request as ready for review
August 10, 2026 20:36
The epic's split, built: everything answerable in TypeScript already runs and gates under DWDC; full .dw validation shells to `dogwood validate` when the binary is present and warns-and-skips with an issue-linked advisory when it is not. - src/dogwood/cli.ts adapts the CLI. Nothing branches on the exit code: exit 2 covers a rejected policy set and clap's own unknown-flag usage error alike, so the JSON on stdout decides and a run that produced none is "unusable", never "rejected". Both JSON shapes are parsed — the ValidateReport and the flattened OpError fatal channel — and internal line/column tails are scrubbed the way wasm-helpers already scrubs cedar-wasm's. `--emit` is not passed, since --format json ignores it. - DWDE010 runs `dogwood validate` over each emitted bundle and maps diagnostics with their byte-offset labels; with no binary it emits exactly one info advisory naming the binary, where chant looked, and #1659. - DWDE011 runs `dogwood lower --format json` and feeds cedar_policies + cedar_schema to @cedar-policy/cedar-wasm validate() — the #1648 traps apply, so success is asserted together with an empty, sorted validationErrors. Silent when lower did not run. - cedar.dogwood.binary joins the config namespace (strictObject kept), with CHANT_DOGWOOD_BINARY covering the chant.config.ts case a synchronous post-synth check cannot read. - Tests inject the runner throughout; a real binary is opt-in behind CHANT_DOGWOOD_E2E and gates nothing. The lowered fixture is adapted from dogwood-policy/dogwood@5063bcc (Apache-2.0), read_after_login. Part of #1646 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018FAMfgpQTVDnsnqJzyHasZ
lex00
force-pushed
the
dogwood/validation
branch
from
August 10, 2026 20:46
7cd77c9 to
2c7d7da
Compare
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 #1659. Part of epic #1646, stacked on
dogwood/dialect(#1658).The cedar release shipped (chant-v0.44.8), so the hold is lifted and this is ready for review. Still based on
dogwood/dialect(#1672) rather thanmain— rebased onto the new tip223c2c03, clean, no conflicts, and the diff is unchanged from the drafted version. Merges after #1672.What the split looks like now
The epic's decision, verbatim: "Everything answerable in TypeScript runs always and gates … Full
.dwvalidation shells todogwood validatewhen present and warns-and-skips when absent — an explicit, issue-linked exception, not a silent one."The DWDC walls #1658 shipped are the always-on half. This adds the other half.
src/dogwood/cli.ts— the adapterLocates a
dogwoodbinary (explicit override →$CHANT_DOGWOOD_BINARY→cedar.dogwood.binary→PATH), runsvalidateandlowerwith--format json, and normalizes both JSON shapes into one result type. The sharp edges from the #1657 report are handled, not assumed away:unusable— reported as "the CLI could not be used", never as "your policy is bad". That is what keeps a flag rename in an upstream sync from failing builds.ValidateReport({passed, passed_without_warnings, errors[], warnings[]}); a fatal parse/macro/lowering error replaces the whole report with a flattenedOpErrorplusrelated[]. Both parse.--emitis not passed, since--format jsonignores it and returns all three lowered artifacts regardless.at line N column Mtail is scrubbed the waywasm-helpers.tsalready scrubs cedar-wasm's.The contract was re-read from the pinned
dogwood-cli/src/{ops,main,error}.rsrather than from the human text — the report structs are the integration surface, the renderer is the part a sync retunes.The two checks
DWDE010dogwood validateover each emitted bundle (policies + action schema + event schema + macros) and maps every diagnostic. Upstream warnings ride along atwarning. A run that could not be made iswarning, noterror. With no binary: exactly oneinfoadvisory naming the binary, where chant looked, and #1659.DWDE011dogwood lower --format json, feedscedar_policies+cedar_schemato@cedar-policy/cedar-wasmvalidate().type === "success"is asserted together with an emptyvalidationErrors, and findings are sorted — the #1648 traps. Silent whenlowerdid not run; DWDE010's advisory covers that once.dogwood-helpers.tsplans the invocations once so the two checks never disagree about what they ran: a macro library is told from a policy set by structure (nopermit/forbidhead) rather than by filename, several libraries concatenate into the one file--macrosaccepts, and several.dwschemafiles mean several runs each naming its own schema instead of one picked silently.Config
cedar.dogwood.binaryjoins the namespace,z.strictObjectintact. It is honoured fromchant.config.json; achant.config.tscannot be read from inside a post-synth check —check()is synchronous andloadChantConfigUpwardis async and may evaluate project code in a sandboxed child — soCHANT_DOGWOOD_BINARYcovers that case. Documented in place rather than pretended away.Tests
Every case injects a runner, and the absent-binary case forces absence rather than hoping the machine has none, so a developer with
dogwoodbuilt locally sees what CI sees. Fixtures cover a passing validate, a rejection, both JSON shapes, the exit-2 ambiguity, a spawn failure, the absent-binary advisory, and a lower+wasm round trip over a checked-in lowered artifact adapted fromdogwood-policy/dogwood@5063bcc2(Apache-2.0),dogwood-docs/examples/read_after_login. An opt-indescribe.skipIfblock exercises a real binary behindCHANT_DOGWOOD_E2E=1; nothing in gating depends on it.Gates
tsc -p lexicons/cedar/tsconfig.build.json— cleannpm run build -w @intentius/chant-lexicon-cedar— cleannpx vitest run lexicons/cedar— 549 passed, 2 skipped (the opt-in pair), 33 filesnpx tsx scripts/check-lexicons.ts— exit 0, cedar 21/21, no new untrackednpx tsx scripts/typecheck.ts— 85 known failures, no regressionsnode scripts/depcheck.mjs— no undeclared runtime dependencies (the adapter uses node builtins only)npx tsx scripts/generate-post-synth-barrels.ts— the committed barrel is byte-identical to the generated one (cedar now ships 16 checks)Re-run in full after the rebase onto
223c2c03.Deviations
.cedarschemabeside them also gets aninfofrom DWDE010, because--policy-schemais not optional and a check that could not run should say so. Same shape as the absent-binary advisory, same issue link.plugin.tsandserializer.tsare untouched — the new checks reach the plugin through the generated post-synth barrel and the audit catalog, so there was nothing to append.