Skip to content

[AAASM-2309] ✨ (scenarios): Add approval-gates/node/ TypeScript implementation#34

Open
Chisanan232 wants to merge 20 commits into
masterfrom
v0.0.1/AAASM-2309/feat/approval_gates_node
Open

[AAASM-2309] ✨ (scenarios): Add approval-gates/node/ TypeScript implementation#34
Chisanan232 wants to merge 20 commits into
masterfrom
v0.0.1/AAASM-2309/feat/approval_gates_node

Conversation

@Chisanan232
Copy link
Copy Markdown
Contributor

What changed

Adds the Node.js/TypeScript sub-project for the scenarios/approval-gates/ scenario. Reads policy.yaml to find rules, evaluates approval_required decisions via MockApprovalClient, and demonstrates the full pending → approved → executed cycle.

Files added (scenarios/approval-gates/node/):

  • src/approval.ts — loads ../policy.yaml, MockApprovalClient, evaluate() handles allow / deny / approval_required
  • src/tools.tsgetBalance (ALLOWED immediately), transferFunds (requires approval)
  • src/index.ts — main demo showing the approval cycle with formatted output
  • tests/smoke.test.ts — 12 vitest tests: policy rules, mock client approve/reject, evaluate outcomes, tool outputs

Related ticket

Closes AAASM-2309

How to verify

cd scenarios/approval-gates/node
pnpm install
pnpm start      # shows pending → approved → executed
pnpm test       # 12 tests pass

Checklist

  • PR title follows [AAASM-XXXX] <GitEmoji> (<scope>): <summary>
  • No secrets, API keys, or .env files committed
  • Example sub-projects include their own README via the scenario-level README
  • SDK/runtime version dependencies are documented or pinned

The SDK is not yet published to npm. Marking it optional lets pnpm install
succeed for the real deps (js-yaml, tsx, vitest) while gracefully skipping
the SDK — consistent with the pattern used by other node sub-projects in
this repo (none carry a lock file until the SDK is published).
@sonarqubecloud
Copy link
Copy Markdown

@Chisanan232
Copy link
Copy Markdown
Contributor Author

Code Review — Claude Code

CI status

Check Result
build ✅ pass
run ✅ pass
SonarCloud ✅ pass

All checks green.

Scope completeness

Verified against AAASM-2309 ticket requirements. All 7 expected Node.js files are present:

  • scenarios/approval-gates/node/package.json
  • scenarios/approval-gates/node/tsconfig.json
  • scenarios/approval-gates/node/src/tools.ts
  • scenarios/approval-gates/node/src/approval.tsMockApprovalClient, evaluate() handling allow/deny/approval_required
  • scenarios/approval-gates/node/src/index.ts
  • scenarios/approval-gates/node/tests/smoke.test.ts — 12 tests ✅
  • scenarios/approval-gates/node/pnpm-lock.yaml

Note on diff size: The PR diff currently includes approval-gates Python and shared files from PR #33 because this branch was stacked on top of it. The extra files disappear once PR #33 merges to master. The net-new scope is solely the node/ directory.

Code quality notes

  • evaluate() handles all three policy actions in a single typed function — clean discriminated union return type ✅
  • MockApprovalClient(false) rejection path covered by tests ✅
  • js-yaml loaded with { schema: yaml.CORE_SCHEMA } — prevents arbitrary code execution via !!js/function tags ✅
  • 12 tests: policy rules, client approve/reject, evaluate outcomes, tool outputs ✅

Verdict

✅ Ready to merge (after PR #33 merges first). All CI green, AAASM-2309 scope fully covered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant