feat: schema introspection command and agent mode#1
Closed
SpollaL wants to merge 1 commit into
Closed
Conversation
- Adds `sentinel schema <file>` subcommand that emits column names, types, null counts, unique counts, and min/max (for numerics) as JSON - Refactors CLI to subcommand-based structure (Validate / Schema) - Adds `--agent` flag (or SENTINEL_AGENT=1 env var) to validate subcommand for machine-readable JSON Lines output with per-rule duration_ms and a final summary line - Structured JSON errors on stderr in agent mode - 11 new tests covering schema introspection and agent mode serialization Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
Merged manually into master via rebase (d85f7d6). |
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
sentinel schema <file>: new subcommand that emits column names, types, null counts, unique counts, and min/max (for numeric columns) as JSON — lets agents understand the data before writing rules--agentflag (orSENTINEL_AGENT=1env var): forces JSON Lines output withrow_countandduration_mson every rule result, plus a structured summary line at the end{"type":"error","code":"...","message":"..."})sentinel validate(existing behavior) andsentinel schema(new)Agent workflow
```bash
1. Understand the data
sentinel schema data.csv
{"columns":[{"name":"id","type":"int64","nulls":0,"unique":1000,"min":1.0,"max":1000.0}],"row_count":1000}
2. Validate with machine-readable output
sentinel validate data.csv -r rules.yaml --agent
{"type":"result","rule":"not_null_id","status":"pass","violations":0,"total":1000,"row_count":1000,"duration_ms":45}
{"type":"result","rule":"email_format","status":"fail","violations":12,"total":1000,"row_count":1000,"duration_ms":67}
{"type":"summary","passed":1,"failed":1,"quality_score":0.5,"duration_ms":312}
```
Test plan
test_introspect_basic— column names and types correcttest_introspect_nulls— null count correcttest_introspect_unique— unique count correct (including duplicates)test_introspect_numeric_min_max— min/max correct for int columnstest_introspect_row_count— row count matchestest_agent_result_serializes_correctly— result JSON has all required fieldstest_agent_summary_serializes_correctly— summary JSON correcttest_agent_error_serializes_correctly— error JSON correcttest_agent_result_is_valid_json_lines— each line independently parseable🤖 Generated with Claude Code