Repository navigation
Description
Defect
The cedar docs show the AgentCore and AVP embedding helpers called inside a resource constructor:
new BedrockAgentCorePolicy({
PolicyEngineId: engine.ref(),
...agentCoreStagedPolicy("writeNeedsApproval", writeNeedsApproval, "log-only"),
});
new VerifiedPermissionsPolicy({
PolicyStoreId: policyStore.ref(),
Definition: avpPolicyDefinition("ownerRead", ownerReadProps, { ... }),
});(lexicons/cedar/docs/pages/dogwood.mdx:135, lexicons/cedar/README.md:259, src/skills/chant-cedar-dogwood.md:196, src/skills/chant-cedar-avp-embedding.md:53.)
chant lint on a project that copies these reports EVL001 on both calls and EVL004 on the spread. Reproduced on main (f3fb201) with a scratch project: EVL001 at the spread and at Definition:, EVL004 at the spread.
The cause is on the lint side. These helpers are pure functions of their arguments that return plain props data, which is what IntrinsicDef.foldsEagerly exists to declare, but the cedar plugin registers no intrinsics, so EVL001 (packages/core/src/fold/subset.ts, the bare-call branch) treats them as arbitrary package calls. EVL004 (packages/core/src/lint/rules/evl004-spread-non-const.ts isTraceableToConst) rejects every call as a spread source, including a registered eager intrinsic, although fold() folds that spread (packages/core/src/fold/fold.ts, eager call branch plus the SpreadAssignment branch).
#5509 hid this in the cedar examples by turning EVL001/EVL004 off in their chant.config.ts. A user following the docs still gets the errors.
The dogwood builders are a separate case. The docs call them through the namespace (dogwood.formerly(...)), which EVL001 already accepts as a method call. Only the two examples destructure them (const { formerly } = dogwood) and call them bare, which EVL001 flags; that is the rest of what #5509 turned off.
Fix
- cedar registers its embedding helpers (
agentCoreStatement,agentCorePolicyDefinition,agentCorePolicyResource,agentCoreStagedPolicy,agentCorePolicyName,avpStatement,avpPolicyDefinition,avpPolicyResource) asfoldsEagerlyintrinsics, so EVL001 accepts them through the registry it already receives. - EVL004 accepts a spread whose source is a call to an intrinsic the active lexicons registered
foldsEagerly, matching whatfold()does. A lexicon that registers nothing gets no change;foldsAsCallintrinsics stay rejected, since they fold to an envelope that cannot be spread. - The two cedar examples call the dogwood builders through
dogwood.as the docs do, and the fix(cedar): turn off the fold-subset lint rules in the dogwood examples #5509 rule overrides are removed. - Docs describe the result.
Activity