Parent guide: ../AGENTS.md
You are an ABCA platform engineer for the @abca/cdk package: Lambda handlers, orchestration, CDK stacks/constructs, IAM, and shared API types.
mise //cdk:compile # TypeScript compile
mise //cdk:test # Jest unit tests
mise //cdk:synth # synth to cdk/cdk.out/
mise //cdk:eslint # ESLint --fix (run after merging main)
mise //cdk:deploy # deploy stack (requires AWS creds)
mise //cdk:diff # diff vs deployed
mise //cdk:destroy # destroy stack- Full suite:
mise //cdk:test - Single file:
cd cdk && npx jest test/handlers/shared/validation.test.ts - Pattern:
cd cdk && npx jest --testPathPattern=orchestrate-task
Extend tests when you change:
| Code | Test location |
|---|---|
| Shared handler logic | cdk/test/handlers/shared/*.test.ts |
| Handler entrypoints | cdk/test/handlers/orchestrate-task.test.ts, create-task.test.ts, webhook-create-task.test.ts |
| Constructs | cdk/test/constructs/task-orchestrator.test.ts, task-api.test.ts |
Construct tests: synthesize each distinct stack config once in beforeAll, assert against cached Template — do not re-synth per test. Bundling is disabled globally via test/setup/disable-bundling.ts (see Common mistakes).
| Path | Access | Purpose |
|---|---|---|
cdk/src/handlers/ |
WRITE | Lambda handlers |
cdk/src/stacks/ |
WRITE | Stack definitions |
cdk/src/constructs/ |
WRITE | Reusable constructs |
cdk/src/handlers/shared/types.ts |
WRITE | API types (mirror to cli/src/types.ts) |
cdk/test/ |
WRITE | Unit / snapshot tests |
cli/src/types.ts |
WRITE (sync) | Must match shared types |
API responses — use successResponse / errorResponse from shared/response.ts; never hand-roll JSON envelopes:
// ✅ Good — contract envelope + typed ErrorCode
import { successResponse, errorResponse, ErrorCode } from '../shared/response';
return successResponse(200, { task_id: taskId }, requestId);
return errorResponse(422, ErrorCode.VALIDATION_ERROR, 'Invalid workflow_ref', requestId);
// ❌ Bad — ad-hoc body, no request ID
return { statusCode: 400, body: JSON.stringify({ error: 'bad' }) };Unit tests — colocate under cdk/test/, descriptive describe/test names:
// ✅ Good
describe('parseBody', () => {
test('returns null for invalid JSON', () => {
expect(parseBody('not json')).toBeNull();
});
});
// ❌ Bad — vague name, no edge cases
test('works', () => { expect(parseBody('{}')).toBeTruthy(); });Construct tests — cache synth output:
// ✅ Good
let template: Template;
beforeAll(() => {
const app = new App();
template = Template.fromStack(new MyStack(app, 'Test'));
});- ✅ Always: Update
cli/src/types.tswhen changingshared/types.ts; add/extend tests incdk/test/; use mise tasks not rawcdkCLI ⚠️ Ask first: New stacks or constructs, IAM policy changes, DynamoDB schema changes, enabling Lambda bundling in unit tests- 🚫 Never: Bump
@cedar-policy/cedar-wasmwithout bumpingcedarpyand refreshingcontracts/cedar-parity/fixtures; re-enable global Lambda bundling in tests; use constructorcontextforaws:cdk:bundling-stacks(usepostCliContextinstead — see #366)
- Lambda bundling in unit tests —
Template.fromStack()synths the stack but bundling is disabled viaCDK_CONTEXT_JSON. Do not re-enable globally; opt in per-test withpostCliContextonly when asserting on bundle output. Details:test/setup/disable-bundling.ts, #366. - Cedar engine drift —
@cedar-policy/cedar-wasmandcedarpyshare a Rust core. Bump both + parity fixtures in one commit. Seedocs/design/CEDAR_HITL_GATES.md§15.6 andmise.tomlparity banner. - Types out of sync —
cdk/src/handlers/shared/types.tsandcli/src/types.tsmust match; CI runscheck-types-sync.