feat: guard playground CLI command (T7)#30
Merged
Conversation
15 scenarios across all 7 guard domains (safe + risky for each, plus edge case for code-merge). Designed to trigger both cross-cutting guard template rules and domain-specific evaluator checks.
Adds `consensus-tools playground` command infrastructure: - playground.ts: 4-vote evaluation (3 cross-cutting guard templates + 1 domain-specific evaluator), hard-block detection, fail-closed error handling, scenario loading with path traversal protection, schema validation on loaded scenarios - playground-renderer.ts: colored vote breakdown table with chalk, truncation, decision banner - Adds @consensus-tools/guards and chalk as CLI dependencies
Top-level `consensus-tools playground` command with flags: --domain, --scenario, --input, --list, --json. Supports canned scenarios, custom JSON input, and file paths. Domain normalization (dash to underscore) for custom input mode.
23 tests covering: scenario loading (valid/invalid/default), input parsing (JSON/file/malformed/missing), evaluation flow (4 votes, ALLOW/BLOCK/REWRITE, hard-block flags, unknown domain, null payload), and renderer output (domain/scenario labels, vote rows, decision banner, flag display, reason truncation).
Track potential chalk replacement with Node 20.12+ built-in util.styleText for reduced CLI dependency footprint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4fb5d69 to
b4989ec
Compare
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.
Summary
Guard Playground (T7) — an interactive CLI tool that makes guard decisions transparent and explorable. The
EXPLAIN ANALYZEfor consensus governance.consensus-tools playgroundruns 4 evaluators against any input and shows a colored vote breakdown:Ships with 15 canned scenarios across all 7 guard domains for zero-config first-run experience.
Commits:
playgroundcommand with --domain, --scenario, --input, --list, --jsonPre-Landing Review
4-pass adversarial review completed (Claude structured + Claude adversarial + Codex structured + Codex adversarial). 10 findings across all passes, all fixed:
Test Coverage
43 tests pass (23 new + 20 existing). Coverage: 87% of code paths tested.
Test plan
consensus-tools playgroundproduces colored output🤖 Generated with Claude Code