Skip to content

feat: schema introspection command and agent mode#1

Closed
SpollaL wants to merge 1 commit into
masterfrom
feat/schema-and-agent-mode
Closed

feat: schema introspection command and agent mode#1
SpollaL wants to merge 1 commit into
masterfrom
feat/schema-and-agent-mode

Conversation

@SpollaL
Copy link
Copy Markdown
Owner

@SpollaL SpollaL commented Apr 23, 2026

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
  • --agent flag (or SENTINEL_AGENT=1 env var): forces JSON Lines output with row_count and duration_ms on every rule result, plus a structured summary line at the end
  • Structured JSON errors on stderr in agent mode ({"type":"error","code":"...","message":"..."})
  • CLI refactored to subcommand structure: sentinel validate (existing behavior) and sentinel 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 correct
  • test_introspect_nulls — null count correct
  • test_introspect_unique — unique count correct (including duplicates)
  • test_introspect_numeric_min_max — min/max correct for int columns
  • test_introspect_row_count — row count matches
  • test_agent_result_serializes_correctly — result JSON has all required fields
  • test_agent_summary_serializes_correctly — summary JSON correct
  • test_agent_error_serializes_correctly — error JSON correct
  • test_agent_result_is_valid_json_lines — each line independently parseable

🤖 Generated with Claude Code

- 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>
@SpollaL
Copy link
Copy Markdown
Owner Author

SpollaL commented Apr 23, 2026

Merged manually into master via rebase (d85f7d6).

@SpollaL SpollaL closed this Apr 23, 2026
@SpollaL SpollaL deleted the feat/schema-and-agent-mode branch April 23, 2026 20:19
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